mirror of https://github.com/apache/openjpa.git
OPENJPA-240 XMLMapping Query testcase
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@557442 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a275b7aefb
commit
b761732fdf
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* 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.xmlmapping.entities;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name="TCUSTOMER")
|
||||||
|
public class Customer {
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
|
public static class CustomerKey {
|
||||||
|
public String countryCode;
|
||||||
|
public int id;
|
||||||
|
|
||||||
|
public CustomerKey(){}
|
||||||
|
|
||||||
|
public CustomerKey(String cc, int id){
|
||||||
|
countryCode=cc;
|
||||||
|
this.id=id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return countryCode+"/"+id;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj){
|
||||||
|
if (obj == this)
|
||||||
|
return true;
|
||||||
|
if (! (obj instanceof CustomerKey))
|
||||||
|
return false;
|
||||||
|
CustomerKey key = (CustomerKey)obj;
|
||||||
|
if (key.countryCode.equals(this.countryCode)
|
||||||
|
&& key.id==this.id)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return this.countryCode.hashCode()
|
||||||
|
^ this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CreditRating { POOR, GOOD, EXCELLENT };
|
||||||
|
|
||||||
|
@EmbeddedId
|
||||||
|
CustomerKey cid;
|
||||||
|
@Column(length=30)
|
||||||
|
String name;
|
||||||
|
@Enumerated
|
||||||
|
CreditRating creditRating;
|
||||||
|
@Embedded
|
||||||
|
EAddress address;
|
||||||
|
@Version
|
||||||
|
long version;
|
||||||
|
|
||||||
|
@OneToMany(fetch=FetchType.LAZY, mappedBy="customer")
|
||||||
|
private Collection<Order> orders = new ArrayList<Order>();
|
||||||
|
|
||||||
|
public Customer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Customer(CustomerKey cid, String name, CreditRating rating) {
|
||||||
|
this.cid=cid;
|
||||||
|
this.name=name;
|
||||||
|
this.creditRating=rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreditRating getRating() {
|
||||||
|
return creditRating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRating(CreditRating rating) {
|
||||||
|
this.creditRating = rating;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Order> getOrders() {
|
||||||
|
return orders;
|
||||||
|
}
|
||||||
|
public void setOrders(Collection<Order> orders) {
|
||||||
|
this.orders = orders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "Customer:" + cid + " name:" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomerKey getCid() {
|
||||||
|
return cid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCid(CustomerKey cid) {
|
||||||
|
this.cid = cid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EAddress getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(EAddress address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* 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.xmlmapping.entities;
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* example of an JPA embeddable class.
|
||||||
|
* This class is used in Customer Entity.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
|
public class EAddress {
|
||||||
|
@Column(columnDefinition="varchar(30)")
|
||||||
|
String street;
|
||||||
|
@Column(columnDefinition="varchar(20)")
|
||||||
|
String city;
|
||||||
|
@Column(columnDefinition="char(2)")
|
||||||
|
String state;
|
||||||
|
@Column(columnDefinition="char(9)")
|
||||||
|
String zip;
|
||||||
|
|
||||||
|
public EAddress() {}
|
||||||
|
|
||||||
|
public EAddress(String street, String city, String state, String zip){
|
||||||
|
this.street = street;
|
||||||
|
this.city = city;
|
||||||
|
this.state = state;
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
public void setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
public String getStreet() {
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
public void setStreet(String street) {
|
||||||
|
this.street = street;
|
||||||
|
}
|
||||||
|
public String getZip() {
|
||||||
|
return zip;
|
||||||
|
}
|
||||||
|
public void setZip(String zip) {
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void modifyCity(String value){
|
||||||
|
city=value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* 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.xmlmapping.entities;
|
||||||
|
|
||||||
|
import org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress.Address;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import org.apache.openjpa.persistence.Persistent;
|
||||||
|
import org.apache.openjpa.persistence.jdbc.Strategy;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name="TORDER")
|
||||||
|
public class Order {
|
||||||
|
@Id
|
||||||
|
int oid;
|
||||||
|
|
||||||
|
double amount;
|
||||||
|
boolean delivered;
|
||||||
|
|
||||||
|
@ManyToOne(fetch=FetchType.LAZY)
|
||||||
|
Customer customer;
|
||||||
|
|
||||||
|
@Persistent
|
||||||
|
@Strategy("org.apache.openjpa.jdbc.meta.strats.XMLValueHandler")
|
||||||
|
Address shipAddress;
|
||||||
|
|
||||||
|
@Version
|
||||||
|
long version;
|
||||||
|
|
||||||
|
public Order(){}
|
||||||
|
|
||||||
|
public Order(int id, double amt, boolean delivered, Customer c) {
|
||||||
|
oid = id;
|
||||||
|
amount = amt;
|
||||||
|
this.delivered = delivered;
|
||||||
|
customer = c;
|
||||||
|
if (c != null)
|
||||||
|
c.getOrders().add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(double amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Customer getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomer(Customer customer) {
|
||||||
|
this.customer = customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDelivered() {
|
||||||
|
return delivered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelivered(boolean delivered) {
|
||||||
|
this.delivered = delivered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOid() {
|
||||||
|
return oid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "Order:" + oid + " amount:" + amount + " delivered:" + delivered
|
||||||
|
+ " customer:" + ((customer != null) ? customer.getCid() : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address getShipAddress() {
|
||||||
|
return shipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShipAddress(Address shipAddress) {
|
||||||
|
this.shipAddress = shipAddress;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,290 @@
|
||||||
|
/*
|
||||||
|
* 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.xmlmapping.query;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.EntityTransaction;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
|
||||||
|
import junit.textui.TestRunner;
|
||||||
|
|
||||||
|
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
||||||
|
import org.apache.openjpa.jdbc.sql.DB2Dictionary;
|
||||||
|
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
||||||
|
import org.apache.openjpa.jdbc.sql.OracleDictionary;
|
||||||
|
import org.apache.openjpa.jdbc.sql.SQLServerDictionary;
|
||||||
|
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||||
|
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||||
|
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||||
|
import org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress.*;
|
||||||
|
import org.apache.openjpa.persistence.xmlmapping.entities.*;
|
||||||
|
import org.apache.openjpa.persistence.xmlmapping.entities.Customer.CreditRating;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test query with predicates on persistent field mapped to XML column.
|
||||||
|
*
|
||||||
|
* @author Catalina Wei
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public class TestXMLCustomerOrder
|
||||||
|
extends SQLListenerTestCase {
|
||||||
|
|
||||||
|
public void setUp() {
|
||||||
|
setUp(org.apache.openjpa.persistence.xmlmapping.entities.Customer.class
|
||||||
|
, org.apache.openjpa.persistence.xmlmapping.entities.Customer.CustomerKey.class
|
||||||
|
, org.apache.openjpa.persistence.xmlmapping.entities.Order.class
|
||||||
|
, org.apache.openjpa.persistence.xmlmapping.entities.EAddress.class
|
||||||
|
, "openjpa.MetaDataRepository"
|
||||||
|
, "org.apache.openjpa.jdbc.meta.XMLMappingRepository"
|
||||||
|
// , "openjpa.ConnectionDriverName"
|
||||||
|
// , "org.apache.commons.dbcp.BasicDataSource"
|
||||||
|
// , "openjpa.ConnectionProperties"
|
||||||
|
// , "DriverClassName=com.ibm.db2.jcc.DB2Driver,Url=jdbc:db2:testdb"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
TestRunner.run(TestXMLCustomerOrder.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testXMLCustomerOrder() {
|
||||||
|
OpenJPAEntityManager em =
|
||||||
|
OpenJPAPersistence.cast(emf.createEntityManager());
|
||||||
|
DBDictionary dict = ((JDBCConfiguration) em.getConfiguration())
|
||||||
|
.getDBDictionaryInstance();
|
||||||
|
|
||||||
|
// skip if dictionary has no support for XML column type
|
||||||
|
if (!dict.supportsXMLColumn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sqllog = TestXMLCustomerOrder.class.getName();
|
||||||
|
sqllog = sqllog.replace('.', '/');
|
||||||
|
sqllog = "./" + sqllog;
|
||||||
|
if (dict instanceof DB2Dictionary)
|
||||||
|
sqllog += ".db2";
|
||||||
|
else if (dict instanceof OracleDictionary)
|
||||||
|
sqllog += ".oracle";
|
||||||
|
else if (dict instanceof SQLServerDictionary)
|
||||||
|
sqllog += ".sqlserver";
|
||||||
|
|
||||||
|
// For platform specific expected sqls are under resources.
|
||||||
|
// The generated sql of the test is captured and written to file:
|
||||||
|
// ./TestXMLCustomerOrder.log
|
||||||
|
// This output file contents should match with the platform specfic sqls.
|
||||||
|
System.out.println("Expected pushdown SQL log file is in: " + sqllog);
|
||||||
|
|
||||||
|
sql.clear();
|
||||||
|
|
||||||
|
try {
|
||||||
|
em.getTransaction().begin();
|
||||||
|
deleteAllData(em );
|
||||||
|
em.getTransaction().commit();
|
||||||
|
|
||||||
|
em.getTransaction().begin();
|
||||||
|
loadData(em);
|
||||||
|
em.getTransaction().commit();
|
||||||
|
|
||||||
|
em.close();
|
||||||
|
|
||||||
|
// By closing and recreating the EntityManager,
|
||||||
|
// this guarantees that data will be retrieved from
|
||||||
|
// the database rather than just reused from the
|
||||||
|
// persistence context created by the load methods above.
|
||||||
|
|
||||||
|
em = emf.createEntityManager();
|
||||||
|
|
||||||
|
System.err.println("Main started.");
|
||||||
|
int test=1;
|
||||||
|
List<Address> addrs = em.createQuery("select o.shipAddress from Order o")
|
||||||
|
.getResultList();
|
||||||
|
for (Address addr : addrs) {
|
||||||
|
System.out.println("addr= " + addr.toString());
|
||||||
|
}
|
||||||
|
String qstrings[] = {
|
||||||
|
"select o from Order o",
|
||||||
|
"select o from Order o, Order o2 where o.shipAddress.city " +
|
||||||
|
"= o2.shipAddress.city",
|
||||||
|
"select o from Order o, Customer c where o.shipAddress.city " +
|
||||||
|
"= c.address.city",
|
||||||
|
"select o from Order o where o.shipAddress.city = 'San Jose'"
|
||||||
|
};
|
||||||
|
String qstring = null;
|
||||||
|
for (int i = 0;i < qstrings.length; i++) {
|
||||||
|
qstring = qstrings[i];
|
||||||
|
List orders = em.createQuery(qstring).getResultList();
|
||||||
|
printOrders(orders, test++);
|
||||||
|
}
|
||||||
|
|
||||||
|
// query passing parameters
|
||||||
|
qstring = "select o from Order o where o.shipAddress.city = ?1";
|
||||||
|
Query q5 = em.createQuery(qstring);
|
||||||
|
q5.setParameter(1, "San Jose");
|
||||||
|
List orders =q5.getResultList();
|
||||||
|
printOrders(orders, test++);
|
||||||
|
|
||||||
|
qstring = "select o from Order o where ?1 = o.shipAddress.city";
|
||||||
|
Query q6 = em.createQuery(qstring);
|
||||||
|
q6.setParameter(1, "San Jose");
|
||||||
|
orders = q6.getResultList();
|
||||||
|
printOrders(orders, test++);
|
||||||
|
|
||||||
|
em.close();
|
||||||
|
|
||||||
|
// test updates
|
||||||
|
em = emf.createEntityManager();
|
||||||
|
testUpdateShipaddress(em, test++);
|
||||||
|
|
||||||
|
em.close();
|
||||||
|
em = emf.createEntityManager();
|
||||||
|
|
||||||
|
// query after updates
|
||||||
|
orders = em.createQuery("select o from Order o").getResultList();
|
||||||
|
System.out.println("After Update:");
|
||||||
|
printOrders(orders, test++);
|
||||||
|
|
||||||
|
// queries expecting exceptions
|
||||||
|
String[] badqstrings = {
|
||||||
|
"select o from Order o where o.shipAddress.city = 95141",
|
||||||
|
"select o from Order o where o.shipAddress.street " +
|
||||||
|
"= '555 Bailey'",
|
||||||
|
"select o from Order o where o.shipAddress.zip = 95141"
|
||||||
|
};
|
||||||
|
for (int i = 0; i < badqstrings.length; i++) {
|
||||||
|
qstring = badqstrings[i];
|
||||||
|
try {
|
||||||
|
System.out.println("\n>> Query "+test+": "+qstring);
|
||||||
|
test++;
|
||||||
|
orders = em.createQuery(qstring).getResultList();
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
System.out.println("Exception: "+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dumpSql();
|
||||||
|
em.close();
|
||||||
|
emf.close();
|
||||||
|
System.out.println("Main ended normally.");
|
||||||
|
} catch (Exception e){
|
||||||
|
System.out.println("Exception: "+e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dumpSql() {
|
||||||
|
String out = "./TestXMLCustomerOrder.log";
|
||||||
|
try {
|
||||||
|
FileWriter fw = new FileWriter(out);
|
||||||
|
for (int i = 0; i < sql.size(); i++) {
|
||||||
|
System.out.println(sql.get(i));
|
||||||
|
fw.write(sql.get(i)+"\n");
|
||||||
|
}
|
||||||
|
fw.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printOrders(List orders, int test) {
|
||||||
|
System.out.println("\n>> Query "+test);
|
||||||
|
System.out.println("result size = "+orders.size());
|
||||||
|
for (int i = 0; i < orders.size(); i++) {
|
||||||
|
printOrder((Order) orders.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData(EntityManager em) {
|
||||||
|
|
||||||
|
ObjectFactory addressFactory = new ObjectFactory();
|
||||||
|
|
||||||
|
Customer c2 = new Customer();
|
||||||
|
c2.setCid( new Customer.CustomerKey("USA", 2) );
|
||||||
|
c2.setName("A&J Auto");
|
||||||
|
c2.setRating( CreditRating.GOOD );
|
||||||
|
c2.setAddress(new EAddress("2480 Campbell Ave", "Campbell", "CA"
|
||||||
|
, "95123"));
|
||||||
|
em.persist(c2);
|
||||||
|
|
||||||
|
Customer c1 = new Customer();
|
||||||
|
c1.setCid( new Customer.CustomerKey("USA", 1) );
|
||||||
|
c1.setName("Harry's Auto");
|
||||||
|
c1.setRating( CreditRating.GOOD );
|
||||||
|
c1.setAddress( new EAddress("12500 Monterey", "San Jose", "CA"
|
||||||
|
, "95141"));
|
||||||
|
em.persist(c1);
|
||||||
|
|
||||||
|
Order o1 = new Order(10, 850, false, c1);
|
||||||
|
USAAddress addr1 = addressFactory.createUSAAddress();
|
||||||
|
addr1.setCity("San Jose");
|
||||||
|
addr1.setState("CA");
|
||||||
|
addr1.setZIP(new Integer("95141"));
|
||||||
|
addr1.getStreet().add("12500 Monterey");
|
||||||
|
addr1.setName( c1.getName());
|
||||||
|
o1.setShipAddress(addr1);
|
||||||
|
em.persist(o1);
|
||||||
|
|
||||||
|
Order o2 = new Order(20, 1000, false, c1);
|
||||||
|
CANAddress addr2 = addressFactory.createCANAddress();
|
||||||
|
addr2.setName(c2.getName());
|
||||||
|
addr2.getStreet().add("123 Warden Road");
|
||||||
|
addr2.setCity("Markham");
|
||||||
|
addr2.setPostalCode("L6G 1C7");
|
||||||
|
addr2.setProvince("ON");
|
||||||
|
o2.setShipAddress(addr2);
|
||||||
|
em.persist(o2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testUpdateShipaddress(EntityManager em, int test)
|
||||||
|
throws Exception {
|
||||||
|
em.getTransaction().begin();
|
||||||
|
String query = "select o from Order o where o.shipAddress.city " +
|
||||||
|
"= 'San Jose'";
|
||||||
|
List orders = em.createQuery(query).getResultList();
|
||||||
|
System.out.println("Before Update: ");
|
||||||
|
printOrders(orders, test);
|
||||||
|
em.getTransaction().commit();
|
||||||
|
|
||||||
|
// update in separate transaction
|
||||||
|
Order o = (Order) orders.get(0);
|
||||||
|
EntityTransaction et = em.getTransaction();
|
||||||
|
et.begin();
|
||||||
|
Address addr = o.getShipAddress();
|
||||||
|
addr.setCity("Cupertino");
|
||||||
|
if (addr instanceof USAAddress)
|
||||||
|
((USAAddress) addr).setZIP(95014);
|
||||||
|
|
||||||
|
// update shipAddress
|
||||||
|
o.setShipAddress(addr);
|
||||||
|
et.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteAllData(EntityManager em) {
|
||||||
|
em.createQuery("delete from Order o").executeUpdate();
|
||||||
|
em.createQuery("delete from Customer c").executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printOrder(Order o){
|
||||||
|
System.out.println(" Customer ID:"+o.getCustomer().getCid());
|
||||||
|
System.out.println(" Order Number:"+o.getOid());
|
||||||
|
System.out.println("Ship to: "+o.getShipAddress().toString());
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2006.10.04 at 03:08:16 PM PDT
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for Address complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="Address">
|
||||||
|
* <complexContent>
|
||||||
|
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||||
|
* <sequence>
|
||||||
|
* <element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* <element name="Street" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="3"/>
|
||||||
|
* <element name="City" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* </sequence>
|
||||||
|
* </restriction>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "Address", propOrder = {
|
||||||
|
"name",
|
||||||
|
"street",
|
||||||
|
"city"
|
||||||
|
})
|
||||||
|
public class Address {
|
||||||
|
|
||||||
|
@XmlElement(name = "Name")
|
||||||
|
protected String name;
|
||||||
|
@XmlElement(name = "Street")
|
||||||
|
protected List<String> street;
|
||||||
|
@XmlElement(name = "City")
|
||||||
|
protected String city;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the name property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the name property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setName(String value) {
|
||||||
|
this.name = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the street property.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This accessor method returns a reference to the live list,
|
||||||
|
* not a snapshot. Therefore any modification you make to the
|
||||||
|
* returned list will be present inside the JAXB object.
|
||||||
|
* This is why there is not a <CODE>set</CODE> method for the street property.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* For example, to add a new item, do as follows:
|
||||||
|
* <pre>
|
||||||
|
* getStreet().add(newItem);
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Objects of the following type(s) are allowed in the list
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public List<String> getStreet() {
|
||||||
|
if (street == null) {
|
||||||
|
street = new ArrayList<String>();
|
||||||
|
}
|
||||||
|
return this.street;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the city property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the city property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setCity(String value) {
|
||||||
|
this.city = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(this.name);
|
||||||
|
for (int i=0; i< this.getStreet().size(); i++)
|
||||||
|
sb.append("\n "+this.getStreet().get(i));
|
||||||
|
sb.append("\n "+this.getCity());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2006.10.04 at 03:08:16 PM PDT
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBElement;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for CAN_Address complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="CAN_Address">
|
||||||
|
* <complexContent>
|
||||||
|
* <extension base="{}Address">
|
||||||
|
* <sequence>
|
||||||
|
* <element name="Province" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* <element name="PostalCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* </sequence>
|
||||||
|
* </extension>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "CAN_Address", propOrder = {
|
||||||
|
"province",
|
||||||
|
"postalCode"
|
||||||
|
})
|
||||||
|
public class CANAddress
|
||||||
|
extends Address
|
||||||
|
{
|
||||||
|
|
||||||
|
@XmlElement(name = "Province")
|
||||||
|
protected String province;
|
||||||
|
@XmlElement(name = "PostalCode")
|
||||||
|
protected String postalCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the province property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getProvince() {
|
||||||
|
return province;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the province property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setProvince(String value) {
|
||||||
|
this.province = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the postalCode property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getPostalCode() {
|
||||||
|
return postalCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the postalCode property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setPostalCode(String value) {
|
||||||
|
this.postalCode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(super.toString())
|
||||||
|
.append("\n ")
|
||||||
|
.append(this.province)
|
||||||
|
.append(" ")
|
||||||
|
.append(this.postalCode);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2006.10.04 at 03:08:16 PM PDT
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBElement;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for GBR_Address complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="GBR_Address">
|
||||||
|
* <complexContent>
|
||||||
|
* <extension base="{}Address">
|
||||||
|
* <sequence>
|
||||||
|
* <element name="County" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* <element name="Postcode" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* </sequence>
|
||||||
|
* </extension>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlRootElement(name = "GBR_Address")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "GBR_Address", propOrder = {
|
||||||
|
"county",
|
||||||
|
"postcode"
|
||||||
|
})
|
||||||
|
public class GBRAddress
|
||||||
|
extends Address
|
||||||
|
{
|
||||||
|
|
||||||
|
@XmlElement(name = "County")
|
||||||
|
protected String county;
|
||||||
|
@XmlElement(name = "Postcode")
|
||||||
|
protected String postcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the county property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getCounty() {
|
||||||
|
return county;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the county property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setCounty(String value) {
|
||||||
|
this.county = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the postcode property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getPostcode() {
|
||||||
|
return postcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the postcode property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setPostcode(String value) {
|
||||||
|
this.postcode = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(super.toString())
|
||||||
|
.append("\n ")
|
||||||
|
.append(this.county)
|
||||||
|
.append(" ")
|
||||||
|
.append(this.postcode);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2006.10.04 at 03:08:16 PM PDT
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementDecl;
|
||||||
|
import javax.xml.bind.annotation.XmlRegistry;
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object contains factory methods for each
|
||||||
|
* Java content interface and Java element interface
|
||||||
|
* generated in the myaddress package.
|
||||||
|
* <p>An ObjectFactory allows you to programatically
|
||||||
|
* construct new instances of the Java representation
|
||||||
|
* for XML content. The Java representation of XML
|
||||||
|
* content can consist of schema derived interfaces
|
||||||
|
* and classes representing the binding of schema
|
||||||
|
* type definitions, element declarations and model
|
||||||
|
* groups. Factory methods for each of these are
|
||||||
|
* provided in this class.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlRegistry
|
||||||
|
public class ObjectFactory {
|
||||||
|
|
||||||
|
private final static QName _AddrUSA_QNAME = new QName("", "AddrUSA");
|
||||||
|
private final static QName _AddrCAN_QNAME = new QName("", "AddrCAN");
|
||||||
|
private final static QName _MailAddress_QNAME = new QName("", "MailAddress");
|
||||||
|
private final static QName _AddrGBR_QNAME = new QName("", "AddrGBR");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: myaddress
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ObjectFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link Address }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Address createAddress() {
|
||||||
|
return new Address();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link ShortAddress }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ShortAddress createShortAddress() {
|
||||||
|
return new ShortAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link USAAddress }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public USAAddress createUSAAddress() {
|
||||||
|
return new USAAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link GBRAddress }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public GBRAddress createGBRAddress() {
|
||||||
|
return new GBRAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link CANAddress }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public CANAddress createCANAddress() {
|
||||||
|
return new CANAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link JAXBElement }{@code <}{@link USAAddress }{@code >}}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlElementDecl(namespace = "", name = "AddrUSA", substitutionHeadNamespace = "", substitutionHeadName = "MailAddress")
|
||||||
|
public JAXBElement<USAAddress> createAddrUSA(USAAddress value) {
|
||||||
|
return new JAXBElement<USAAddress>(_AddrUSA_QNAME, USAAddress.class, null, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link JAXBElement }{@code <}{@link CANAddress }{@code >}}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlElementDecl(namespace = "", name = "AddrCAN", substitutionHeadNamespace = "", substitutionHeadName = "MailAddress")
|
||||||
|
public JAXBElement<CANAddress> createAddrCAN(CANAddress value) {
|
||||||
|
return new JAXBElement<CANAddress>(_AddrCAN_QNAME, CANAddress.class, null, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link JAXBElement }{@code <}{@link Address }{@code >}}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlElementDecl(namespace = "", name = "MailAddress")
|
||||||
|
public JAXBElement<Address> createMailAddress(Address value) {
|
||||||
|
return new JAXBElement<Address>(_MailAddress_QNAME, Address.class, null, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of {@link JAXBElement }{@code <}{@link GBRAddress }{@code >}}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlElementDecl(namespace = "", name = "AddrGBR", substitutionHeadNamespace = "", substitutionHeadName = "MailAddress")
|
||||||
|
public JAXBElement<GBRAddress> createAddrGBR(GBRAddress value) {
|
||||||
|
return new JAXBElement<GBRAddress>(_AddrGBR_QNAME, GBRAddress.class, null, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2006.10.04 at 03:08:16 PM PDT
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for ShortAddress complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="ShortAddress">
|
||||||
|
* <complexContent>
|
||||||
|
* <restriction base="{}Address">
|
||||||
|
* <sequence>
|
||||||
|
* <element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* <element name="Street" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* <element name="City" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* </sequence>
|
||||||
|
* </restriction>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "ShortAddress")
|
||||||
|
public class ShortAddress
|
||||||
|
extends Address
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
//
|
||||||
|
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
|
||||||
|
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
|
||||||
|
// Any modifications to this file will be lost upon recompilation of the source schema.
|
||||||
|
// Generated on: 2006.10.04 at 03:08:16 PM PDT
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementDecl;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for USA_Address complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <complexType name="USA_Address">
|
||||||
|
* <complexContent>
|
||||||
|
* <extension base="{}Address">
|
||||||
|
* <sequence>
|
||||||
|
* <element name="State" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||||
|
* <element name="ZIP" type="{}USPS_ZIP"/>
|
||||||
|
* </sequence>
|
||||||
|
* </extension>
|
||||||
|
* </complexContent>
|
||||||
|
* </complexType>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@XmlRootElement
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@XmlType(name = "USA_Address", propOrder = {
|
||||||
|
"state",
|
||||||
|
"zip"
|
||||||
|
})
|
||||||
|
public class USAAddress
|
||||||
|
extends Address
|
||||||
|
{
|
||||||
|
|
||||||
|
@XmlElement(name = "State")
|
||||||
|
protected String state;
|
||||||
|
@XmlElement(name = "ZIP")
|
||||||
|
protected int zip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the state property.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* possible object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the state property.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* allowed object is
|
||||||
|
* {@link String }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setState(String value) {
|
||||||
|
this.state = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the zip property.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int getZIP() {
|
||||||
|
return zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the zip property.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setZIP(int value) {
|
||||||
|
this.zip = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append(super.toString())
|
||||||
|
.append("\n ")
|
||||||
|
.append(this.state)
|
||||||
|
.append(" ")
|
||||||
|
.append(this.zip);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
DELETE FROM TORDER t0
|
||||||
|
SELECT t0.countryCode, t0.id, t0.version, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0
|
||||||
|
DELETE FROM TCUSTOMER WHERE countryCode = ? AND id = ? AND version = ?
|
||||||
|
DELETE FROM TCUSTOMER WHERE countryCode = ? AND id = ? AND version = ?
|
||||||
|
INSERT INTO TORDER (oid, amount, delivered, shipAddress, version, customer_countryCode, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TCUSTOMER (countryCode, id, creditRating, name, version, city, state, street, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TCUSTOMER (countryCode, id, creditRating, name, version, city, state, street, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TORDER (oid, amount, delivered, shipAddress, version, customer_countryCode, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
SELECT t0.shipAddress FROM TORDER t0
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ? optimize for 1 row
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 JOIN TORDER t1 ON (1 = 1) WHERE (XMLEXISTS('$t0.shipAddress/*[City = $t1.shipAddress/*/City]' PASSING t0.shipAddress AS "t0.shipAddress", t1.shipAddress AS "t1.shipAddress"))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 JOIN TCUSTOMER t1 ON (1 = 1) WHERE (XMLEXISTS('$t0.shipAddress/*[City = $t1.city]' PASSING t0.shipAddress AS "t0.shipAddress", t1.city AS "t1.city"))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (XMLEXISTS('$t0.shipAddress/*[City = $Parm]' PASSING t0.shipAddress AS "t0.shipAddress", CAST(? AS VARCHAR(254)) AS "Parm"))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (XMLEXISTS('$t0.shipAddress/*[City = $Parm]' PASSING t0.shipAddress AS "t0.shipAddress", CAST(? AS VARCHAR(254)) AS "Parm"))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (XMLEXISTS('$t0.shipAddress/*[City = $Parm]' PASSING t0.shipAddress AS "t0.shipAddress", CAST(? AS VARCHAR(254)) AS "Parm"))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (XMLEXISTS('$t0.shipAddress/*[City = $Parm]' PASSING t0.shipAddress AS "t0.shipAddress", CAST(? AS VARCHAR(254)) AS "Parm"))
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ? optimize for 1 row
|
||||||
|
UPDATE TORDER SET shipAddress = ?, version = ? WHERE oid = ? AND version = ?
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ? optimize for 1 row
|
|
@ -0,0 +1,21 @@
|
||||||
|
DELETE FROM TORDER t0
|
||||||
|
SELECT t0.countryCode, t0.id, t0.version, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0
|
||||||
|
DELETE FROM TCUSTOMER WHERE countryCode = ? AND id = ? AND version = ?
|
||||||
|
DELETE FROM TCUSTOMER WHERE countryCode = ? AND id = ? AND version = ?
|
||||||
|
INSERT INTO TORDER (oid, amount, delivered, shipAddress, version, customer_countryCode, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TORDER (oid, amount, delivered, shipAddress, version, customer_countryCode, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TCUSTOMER (countryCode, id, creditRating, name, version, city, state, street, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TCUSTOMER (countryCode, id, creditRating, name, version, city, state, street, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
SELECT t0.shipAddress.getStringVal() FROM TORDER t0
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ?
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0, TORDER t1 WHERE (extractValue(t0.shipAddress,'/*/City') = extractValue(t1.shipAddress,'/*/City'))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0, TCUSTOMER t1 WHERE (extractValue(t0.shipAddress,'/*/City') = t1.city)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0 WHERE (extractValue(t0.shipAddress,'/*/City') = ?)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0 WHERE (extractValue(t0.shipAddress,'/*/City') = ?)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0 WHERE (extractValue(t0.shipAddress,'/*/City') = ?)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0 WHERE (extractValue(t0.shipAddress,'/*/City') = ?)
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ?
|
||||||
|
UPDATE TORDER SET shipAddress = ?, version = ? WHERE oid = ? AND version = ?
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress.getStringVal() FROM TORDER t0
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ?
|
|
@ -0,0 +1,21 @@
|
||||||
|
DELETE FROM TORDER
|
||||||
|
SELECT t0.countryCode, t0.id, t0.version, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0
|
||||||
|
DELETE FROM TCUSTOMER WHERE countryCode = ? AND id = ? AND version = ?
|
||||||
|
DELETE FROM TCUSTOMER WHERE countryCode = ? AND id = ? AND version = ?
|
||||||
|
INSERT INTO TORDER (oid, amount, delivered, shipAddress, version, customer_countryCode, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TORDER (oid, amount, delivered, shipAddress, version, customer_countryCode, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TCUSTOMER (countryCode, id, creditRating, name, version, city, state, street, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
INSERT INTO TCUSTOMER (countryCode, id, creditRating, name, version, city, state, street, zip) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
SELECT t0.shipAddress FROM TORDER t0
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ?
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 CROSS JOIN TORDER t1 WHERE (t0.shipAddress.value('(/*/City/text())[1]','VARCHAR(255)') = t1.shipAddress.value('(/*/City/text())[1]','VARCHAR(255)'))
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 CROSS JOIN TCUSTOMER t1 WHERE (t0.shipAddress.exist('/*[City = sql:column("t1.city")]') = 1)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (t0.shipAddress.value('(/*/City/text())[1]','VARCHAR(255)') = ?)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (t0.shipAddress.value('(/*/City/text())[1]','VARCHAR(255)') = ?)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (t0.shipAddress.value('(/*/City/text())[1]','VARCHAR(255)') = ?)
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0 WHERE (t0.shipAddress.value('(/*/City/text())[1]','VARCHAR(255)') = ?)
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ?
|
||||||
|
UPDATE TORDER SET shipAddress = ?, version = ? WHERE oid = ? AND version = ?
|
||||||
|
SELECT t0.oid, t0.version, t0.amount, t0.customer_countryCode, t0.customer_id, t0.delivered, t0.shipAddress FROM TORDER t0
|
||||||
|
SELECT t0.version, t0.countryCode, t0.id, t0.city, t0.state, t0.street, t0.zip, t0.name FROM TCUSTOMER t0 WHERE t0.countryCode = ? AND t0.id = ?
|
Loading…
Reference in New Issue