Fixing svn:eol-style

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@806726 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2009-08-21 21:28:08 +00:00
parent bb7048d27c
commit 7c8454767e
4 changed files with 371 additions and 371 deletions

View File

@ -1,66 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.embed;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
@Embeddable
public class Listing {
@ManyToOne(cascade=CascadeType.ALL)
Seller seller;
Double price;
String comments;
public Listing(){}
public Listing(Seller seller, Double price){
this.price=price;
this.seller=seller;
}
public Seller getSeller() {
return seller;
}
public void setSeller(Seller seller) {
this.seller = seller;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.embed;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
@Embeddable
public class Listing {
@ManyToOne(cascade=CascadeType.ALL)
Seller seller;
Double price;
String comments;
public Listing(){}
public Listing(Seller seller, Double price){
this.price=price;
this.seller=seller;
}
public Seller getSeller() {
return seller;
}
public void setSeller(Seller seller) {
this.seller = seller;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
}

View File

@ -1,69 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.embed;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="SL_EMD")
public class Seller {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String name;
public Seller(){
}
public Seller(String n){
name=n;
}
/*
public Seller(String n, int id){
name=n;
this.id = id;
}
*/
public int getId() {
return id;
}
/*
public void setId(int id) {
this.id = id;
}
*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString(){
return "Seller id: " + id + " name: " + name;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.embed;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="SL_EMD")
public class Seller {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String name;
public Seller(){
}
public Seller(String n){
name=n;
}
/*
public Seller(String n, int id){
name=n;
this.id = id;
}
*/
public int getId() {
return id;
}
/*
public void setId(int id) {
this.id = id;
}
*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString(){
return "Seller id: " + id + " name: " + name;
}
}

View File

@ -1,155 +1,155 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.embed;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import org.apache.openjpa.persistence.ArgumentException;
import org.apache.openjpa.persistence.RollbackException;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
public class TestUpdateEmbeddedQueryResult extends SingleEMFTestCase {
public int ID = 1;
public void setUp() {
setUp(Embed.class,
Embed_Embed.class,
EntityA_Embed_Embed.class,
DROP_TABLES);
}
public void testEntityA_Embed_Embed_update() {
createEntityA_Embed_Embed();
updateEmbedded_EntityA_Embed_Embed();
}
/*
* Create EntityA_Embed_Embed
*/
public void createEntityA_Embed_Embed() {
EntityManager em = emf.createEntityManager();
EntityTransaction tran = em.getTransaction();
createEntityA_Embed_Embed(em, ID);
tran.begin();
em.flush();
tran.commit();
em.close();
}
public void createEntityA_Embed_Embed(EntityManager em, int id) {
EntityA_Embed_Embed a = new EntityA_Embed_Embed();
a.setId(id);
a.setName("a" + id);
a.setAge(id);
Embed_Embed embed = createEmbed_Embed(em, id, 0);
a.setEmbed(embed);
em.persist(a);
}
public Embed_Embed createEmbed_Embed(EntityManager em, int id, int idx) {
Embed_Embed embed = new Embed_Embed();
embed.setIntVal1(id * 100 + idx * 10 + 1);
embed.setIntVal2(id * 100 + idx * 10 + 2);
embed.setIntVal3(id * 100 + idx * 10 + 3);
Embed embed1 = createEmbed(id, idx);
embed.setEmbed(embed1);
return embed;
}
public Embed createEmbed(int id, int idx) {
Embed embed = new Embed();
embed.setIntVal1(id * 100 + idx * 10 + 4);
embed.setIntVal2(id * 100 + idx * 10 + 5);
embed.setIntVal3(id * 100 + idx * 10 + 6);
return embed;
}
/*
*
*/
public void testBulkUpdateEmbeddedField() {
EntityManager em = emf.createEntityManager();
String update = "UPDATE EntityA_Embed_Embed a set a.embed.embed.intVal1 = ?1," +
" a.embed.embed.intVal2 = ?2 where a.id = 10";
em.getTransaction().begin();
int count = em.createQuery(update).setParameter(1, 100).setParameter(2, 200).executeUpdate();
em.getTransaction().commit();
assertEquals(count, 0);
// test invalid bulk update embeddable field
update = "UPDATE EntityA_Embed_Embed a set a.embed.embed = ?1";
Embed embed1 = createEmbed(ID, 10);
try {
int updateCount = em.createQuery(update).setParameter(1, embed1).executeUpdate();
} catch (ArgumentException e) {
// as expected: Bulk update of embeddable field is not allowed.
}
em.close();
}
/*
* update embedded object returned from query
*/
public void updateEmbedded_EntityA_Embed_Embed() {
EntityManager em = emf.createEntityManager();
// test update embedded object returned from query
String query[] = {
"select a.embed from EntityA_Embed_Embed a",
"select a.embed.embed from EntityA_Embed_Embed a",
"select a.embed as e from EntityA_Embed_Embed a ORDER BY e",
};
List rs = null;
Embed_Embed embedembed = null;
Embed embed = null;
EntityTransaction tran = em.getTransaction();
tran.begin();
for (int i = 0; i < query.length; i++) {
rs = em.createQuery(query[i]).getResultList();
assertTrue(rs.size() > 0);
try {
switch (i) {
case 0:
case 2:
embedembed = (Embed_Embed) rs.get(0);
embedembed.getEmbed().setIntVal1(1111);
embedembed.setEmbed(embed);
break;
case 1:
embed = (Embed) rs.get(0);
embed.setIntVal1(1111);
break;
}
} catch(ArgumentException e) {
// as expected:
// Update of embedded object returned from query result is not allowed.
}
}
try {
tran.commit();
} catch(RollbackException e) {
// as expected:
// Update of embedded object returned from query result is not allowed.
}
em.close();
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.embed;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import org.apache.openjpa.persistence.ArgumentException;
import org.apache.openjpa.persistence.RollbackException;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
public class TestUpdateEmbeddedQueryResult extends SingleEMFTestCase {
public int ID = 1;
public void setUp() {
setUp(Embed.class,
Embed_Embed.class,
EntityA_Embed_Embed.class,
DROP_TABLES);
}
public void testEntityA_Embed_Embed_update() {
createEntityA_Embed_Embed();
updateEmbedded_EntityA_Embed_Embed();
}
/*
* Create EntityA_Embed_Embed
*/
public void createEntityA_Embed_Embed() {
EntityManager em = emf.createEntityManager();
EntityTransaction tran = em.getTransaction();
createEntityA_Embed_Embed(em, ID);
tran.begin();
em.flush();
tran.commit();
em.close();
}
public void createEntityA_Embed_Embed(EntityManager em, int id) {
EntityA_Embed_Embed a = new EntityA_Embed_Embed();
a.setId(id);
a.setName("a" + id);
a.setAge(id);
Embed_Embed embed = createEmbed_Embed(em, id, 0);
a.setEmbed(embed);
em.persist(a);
}
public Embed_Embed createEmbed_Embed(EntityManager em, int id, int idx) {
Embed_Embed embed = new Embed_Embed();
embed.setIntVal1(id * 100 + idx * 10 + 1);
embed.setIntVal2(id * 100 + idx * 10 + 2);
embed.setIntVal3(id * 100 + idx * 10 + 3);
Embed embed1 = createEmbed(id, idx);
embed.setEmbed(embed1);
return embed;
}
public Embed createEmbed(int id, int idx) {
Embed embed = new Embed();
embed.setIntVal1(id * 100 + idx * 10 + 4);
embed.setIntVal2(id * 100 + idx * 10 + 5);
embed.setIntVal3(id * 100 + idx * 10 + 6);
return embed;
}
/*
*
*/
public void testBulkUpdateEmbeddedField() {
EntityManager em = emf.createEntityManager();
String update = "UPDATE EntityA_Embed_Embed a set a.embed.embed.intVal1 = ?1," +
" a.embed.embed.intVal2 = ?2 where a.id = 10";
em.getTransaction().begin();
int count = em.createQuery(update).setParameter(1, 100).setParameter(2, 200).executeUpdate();
em.getTransaction().commit();
assertEquals(count, 0);
// test invalid bulk update embeddable field
update = "UPDATE EntityA_Embed_Embed a set a.embed.embed = ?1";
Embed embed1 = createEmbed(ID, 10);
try {
int updateCount = em.createQuery(update).setParameter(1, embed1).executeUpdate();
} catch (ArgumentException e) {
// as expected: Bulk update of embeddable field is not allowed.
}
em.close();
}
/*
* update embedded object returned from query
*/
public void updateEmbedded_EntityA_Embed_Embed() {
EntityManager em = emf.createEntityManager();
// test update embedded object returned from query
String query[] = {
"select a.embed from EntityA_Embed_Embed a",
"select a.embed.embed from EntityA_Embed_Embed a",
"select a.embed as e from EntityA_Embed_Embed a ORDER BY e",
};
List rs = null;
Embed_Embed embedembed = null;
Embed embed = null;
EntityTransaction tran = em.getTransaction();
tran.begin();
for (int i = 0; i < query.length; i++) {
rs = em.createQuery(query[i]).getResultList();
assertTrue(rs.size() > 0);
try {
switch (i) {
case 0:
case 2:
embedembed = (Embed_Embed) rs.get(0);
embedembed.getEmbed().setIntVal1(1111);
embedembed.setEmbed(embed);
break;
case 1:
embed = (Embed) rs.get(0);
embed.setIntVal1(1111);
break;
}
} catch(ArgumentException e) {
// as expected:
// Update of embedded object returned from query result is not allowed.
}
}
try {
tran.commit();
} catch(RollbackException e) {
// as expected:
// Update of embedded object returned from query result is not allowed.
}
em.close();
}
}

View File

@ -1,81 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.query;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
* Persistent class used in testing subquery.
*/
@Entity
@Table(name="ACCT")
public class Account {
@Id
@GeneratedValue
private long aid;
private int balance;
private Integer loan;
@ManyToOne
private Customer cust;
private String name;
public long getId() {
return aid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
this.balance = balance;
}
public Integer getLoan() {
return loan;
}
public void setLoan(Integer loan) {
this.loan = loan;
}
public Customer getCustomer() {
return cust;
}
public void setCustomer(Customer customer) {
this.cust = customer;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.query;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
* Persistent class used in testing subquery.
*/
@Entity
@Table(name="ACCT")
public class Account {
@Id
@GeneratedValue
private long aid;
private int balance;
private Integer loan;
@ManyToOne
private Customer cust;
private String name;
public long getId() {
return aid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
this.balance = balance;
}
public Integer getLoan() {
return loan;
}
public void setLoan(Integer loan) {
this.loan = loan;
}
public Customer getCustomer() {
return cust;
}
public void setCustomer(Customer customer) {
this.cust = customer;
}
}