From a5ed9f701dcb37ffd020e5333bcd0c28b26d650d Mon Sep 17 00:00:00 2001 From: "David J. Wisneski" Date: Sat, 21 Jul 2007 01:25:48 +0000 Subject: [PATCH] OPENJPA-240 XMLMapping Query support, fix eol delimiters to unix style git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@558221 13f79535-47bb-0310-9956-ffa450edef68 --- .../jdbc/meta/XMLMappingRepository.java | 164 ++--- .../apache/openjpa/meta/XMLClassMetaData.java | 454 +++++++------- .../org/apache/openjpa/meta/XMLMapping.java | 238 +++---- .../org/apache/openjpa/meta/XMLMetaData.java | 222 +++---- .../xmlmapping/entities/Customer.java | 262 ++++---- .../xmlmapping/entities/EAddress.java | 150 ++--- .../xmlmapping/entities/Order.java | 196 +++--- .../query/TestXMLCustomerOrder.java | 586 +++++++++--------- .../xmlbindings/myaddress/Address.java | 284 ++++----- .../xmlbindings/myaddress/CANAddress.java | 222 +++---- .../xmlbindings/myaddress/GBRAddress.java | 222 +++---- .../xmlbindings/myaddress/ObjectFactory.java | 244 ++++---- .../xmlbindings/myaddress/ShortAddress.java | 92 +-- .../xmlbindings/myaddress/USAAddress.java | 206 +++--- 14 files changed, 1771 insertions(+), 1771 deletions(-) diff --git a/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/XMLMappingRepository.java b/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/XMLMappingRepository.java index 6352505bd..f2cadb8b6 100644 --- a/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/XMLMappingRepository.java +++ b/openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/XMLMappingRepository.java @@ -1,82 +1,82 @@ -/* - * 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.jdbc.meta; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.openjpa.meta.FieldMetaData; -import org.apache.openjpa.meta.XMLClassMetaData; -import org.apache.openjpa.meta.XMLMapping; - -/** - * Repository of object/relational mapping information. - * (extended to include XML mapping metadata for XML columns) - * - * @author Catalina Wei - * @since 1.0.0 - */ -public class XMLMappingRepository extends MappingRepository { - // xml mapping - protected final XMLMapping[] EMPTY_XMLMETAS; - private final Map _xmlmetas = new HashMap(); - - public XMLMappingRepository() { - super(); - EMPTY_XMLMETAS = newXMLClassMetaDataArray(0); - } - - public synchronized XMLClassMetaData addXMLClassMetaData(FieldMetaData fmd, - String name) { - XMLClassMetaData meta = newXMLClassMetaData(fmd, name); - addXMLClassMetaData(fmd.getDeclaredType(), meta); - return meta; - } - - public XMLMapping getXMLClassMetaData(Class cls) { - synchronized(_xmlmetas) { - if (_xmlmetas.isEmpty()) - return null; - else - return (XMLClassMetaData) _xmlmetas.get(cls); - } - } - - public XMLMapping getXMLMetaData(FieldMetaData fmd) { - XMLMapping xmlmeta = null; - if (XMLClassMetaData.isXMLMapping(fmd.getDeclaredType())) { - xmlmeta = getXMLClassMetaData(fmd.getDeclaredType()); - if (xmlmeta == null) - xmlmeta = addXMLClassMetaData(fmd, fmd.getName()); - } - return xmlmeta; - } - - public synchronized void addXMLClassMetaData(Class cls, XMLMapping meta) { - _xmlmetas.put(cls, meta); - } - - protected XMLClassMetaData newXMLClassMetaData(FieldMetaData fmd, String name) { - return new XMLClassMetaData(fmd.getDeclaredType(), name, this); - } - - protected XMLMapping[] newXMLClassMetaDataArray(int length) { - return new XMLClassMetaData[length]; - } -} +/* + * 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.jdbc.meta; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.openjpa.meta.FieldMetaData; +import org.apache.openjpa.meta.XMLClassMetaData; +import org.apache.openjpa.meta.XMLMapping; + +/** + * Repository of object/relational mapping information. + * (extended to include XML mapping metadata for XML columns) + * + * @author Catalina Wei + * @since 1.0.0 + */ +public class XMLMappingRepository extends MappingRepository { + // xml mapping + protected final XMLMapping[] EMPTY_XMLMETAS; + private final Map _xmlmetas = new HashMap(); + + public XMLMappingRepository() { + super(); + EMPTY_XMLMETAS = newXMLClassMetaDataArray(0); + } + + public synchronized XMLClassMetaData addXMLClassMetaData(FieldMetaData fmd, + String name) { + XMLClassMetaData meta = newXMLClassMetaData(fmd, name); + addXMLClassMetaData(fmd.getDeclaredType(), meta); + return meta; + } + + public XMLMapping getXMLClassMetaData(Class cls) { + synchronized(_xmlmetas) { + if (_xmlmetas.isEmpty()) + return null; + else + return (XMLClassMetaData) _xmlmetas.get(cls); + } + } + + public XMLMapping getXMLMetaData(FieldMetaData fmd) { + XMLMapping xmlmeta = null; + if (XMLClassMetaData.isXMLMapping(fmd.getDeclaredType())) { + xmlmeta = getXMLClassMetaData(fmd.getDeclaredType()); + if (xmlmeta == null) + xmlmeta = addXMLClassMetaData(fmd, fmd.getName()); + } + return xmlmeta; + } + + public synchronized void addXMLClassMetaData(Class cls, XMLMapping meta) { + _xmlmetas.put(cls, meta); + } + + protected XMLClassMetaData newXMLClassMetaData(FieldMetaData fmd, String name) { + return new XMLClassMetaData(fmd.getDeclaredType(), name, this); + } + + protected XMLMapping[] newXMLClassMetaDataArray(int length) { + return new XMLClassMetaData[length]; + } +} diff --git a/openjpa-jdbc-5/src/main/java/org/apache/openjpa/meta/XMLClassMetaData.java b/openjpa-jdbc-5/src/main/java/org/apache/openjpa/meta/XMLClassMetaData.java index 0037f24a1..5e6d9256b 100644 --- a/openjpa-jdbc-5/src/main/java/org/apache/openjpa/meta/XMLClassMetaData.java +++ b/openjpa-jdbc-5/src/main/java/org/apache/openjpa/meta/XMLClassMetaData.java @@ -1,227 +1,227 @@ -/* - * 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.meta; - -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Member; -import java.lang.reflect.Field; -import java.util.HashMap; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.apache.openjpa.jdbc.meta.XMLMappingRepository; -import org.apache.openjpa.meta.JavaTypes; -import org.apache.openjpa.meta.XMLMapping; -import org.apache.openjpa.meta.XMLMetaData; -import org.apache.commons.lang.StringUtils; - -/** - * Contains metadata about a persistent field that maps to an xml column. - * This metadata is loaded at runtime when query involves predicates - * that navigate through xpath. - * - * @author Catalina Wei - * @since 1.0.0 - */ -public class XMLClassMetaData implements XMLMapping -{ - private Class _type; - private int _code = JavaTypes.OBJECT; - private int _xmltype = XMLTYPE; - private String _name = null; - private String _xmlname = null; - private String _xmlnamespace = null; - private boolean _isXMLRootElement = false; - private HashMap _fieldMap = new HashMap(); - - /** - * Constructor. - * - * @param type the class that contains XmlType annotation. - * @name the persistent field name that maps to xml column - * @param repo the meta repository. - */ - public XMLClassMetaData(Class type, String name, XMLMappingRepository repos) { - _type = type; - _isXMLRootElement = _type.getAnnotation(XmlRootElement.class) != null; - if (_isXMLRootElement) { - _xmlname = ((XmlRootElement) _type.getAnnotation - (XmlRootElement.class)).name(); - _xmlnamespace = ((XmlRootElement) _type.getAnnotation - (XmlRootElement.class)).namespace(); - } - else { - _xmlname = ((XmlType) _type.getAnnotation - (XmlType.class)).name(); - _xmlnamespace = ((XmlType) _type.getAnnotation - (XmlType.class)).namespace(); - _name = name; - } - populateFromReflection(_type, repos); - } - - /** - * Constructor. Supply described type and repository. - * - * @param type the class that contains XmlType annotation. - * @param repo the meta repository. - */ - protected XMLClassMetaData(Class type, XMLMappingRepository repos) { - _type = type; - _isXMLRootElement = _type.getAnnotation(XmlRootElement.class) != null; - if (_isXMLRootElement) { - _xmlname = ((XmlRootElement) _type.getAnnotation - (XmlRootElement.class)).name(); - _xmlnamespace = ((XmlRootElement) _type.getAnnotation - (XmlRootElement.class)).namespace(); - } - else { - _xmlname = ((XmlType) _type.getAnnotation - (XmlType.class)).name(); - _xmlnamespace = ((XmlType) _type.getAnnotation - (XmlType.class)).namespace(); - } - populateFromReflection(_type, repos); - repos.addXMLClassMetaData(type, this); - } - - /** - * Given a class type return true if XmlType annotation exists - * @param type - * @return true if XmlType annotation is present else false. - */ - public static boolean isXMLMapping(Class type) { - return type.isAnnotationPresent(XmlType.class); - } - - public void setName(String name) { - _name = name; - } - - public String getName() { - return _name; - } - - public void setXmlname(String name) { - _xmlname = name; - } - - public String getXmlname() { - return _isXMLRootElement ? null : _xmlname; - } - - public void setXmlnamespace(String name) { - // avoid JAXB XML bind default name - if (!StringUtils.equals(defaultName, name)) - _xmlnamespace = name; - } - - public String getXmlnamespace() { - return _xmlnamespace; - } - - public boolean isXmlRootElement() { - return _isXMLRootElement; - } - - public boolean isXmlElement() { - return false; - } - - public boolean isXmlAttribute() { - return false; - } - - public XMLMapping getFieldMapping(String name) { - return (XMLMapping) _fieldMap.get(name); - } - - public void setType(Class type) { - _type = type; - } - - public Class getType() { - return _type; - } - - public int getTypeCode() { - return _code; - } - - public void setXmltype(int type) { - _xmltype = type; - } - public int getXmltype() { - return _xmltype; - } - - private synchronized void populateFromReflection(Class cls, - XMLMappingRepository repos) { - Member[] members; - if (((XmlAccessorType)cls.getAnnotation(XmlAccessorType.class)).value() - == XmlAccessType.FIELD) - members = cls.getDeclaredFields(); - else - members = cls.getDeclaredMethods(); - for (int i = 0; i < members.length; i++) { - Member member = members[i]; - AnnotatedElement el = (AnnotatedElement) member; - XMLMapping field = null; - if (el.getAnnotation(XmlElement.class) != null) { - String xmlname = el.getAnnotation(XmlElement.class).name(); - // avoid JAXB XML bind default name - if (StringUtils.equals(defaultName, xmlname)) - xmlname = member.getName(); - if (((Field) member).getType(). - isAnnotationPresent(XmlType.class)) { - field = new XMLClassMetaData(((Field) member).getType(), - repos); - field.setXmltype(XMLTYPE); - field.setXmlname(xmlname); - } - else { - field = new XMLMetaData(); - field.setXmltype(ELEMENT); - field.setXmlname(xmlname); - field.setXmlnamespace(el.getAnnotation(XmlElement.class) - .namespace()); - } - } - else if (el.getAnnotation(XmlAttribute.class) != null) { - field = new XMLMetaData(); - field.setXmltype(XMLMetaData.ATTRIBUTE); - String xmlname = el.getAnnotation(XmlAttribute.class).name(); - // avoid JAXB XML bind default name - if (StringUtils.equals(defaultName, xmlname)) - xmlname = member.getName(); - field.setXmlname("@"+xmlname); - field.setXmlnamespace(el.getAnnotation(XmlAttribute.class) - .namespace()); - } - field.setName(member.getName()); - field.setType(((Field) member).getType()); - _fieldMap.put(member.getName(), field); - } - } -} +/* + * 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.meta; + +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Member; +import java.lang.reflect.Field; +import java.util.HashMap; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import org.apache.openjpa.jdbc.meta.XMLMappingRepository; +import org.apache.openjpa.meta.JavaTypes; +import org.apache.openjpa.meta.XMLMapping; +import org.apache.openjpa.meta.XMLMetaData; +import org.apache.commons.lang.StringUtils; + +/** + * Contains metadata about a persistent field that maps to an xml column. + * This metadata is loaded at runtime when query involves predicates + * that navigate through xpath. + * + * @author Catalina Wei + * @since 1.0.0 + */ +public class XMLClassMetaData implements XMLMapping +{ + private Class _type; + private int _code = JavaTypes.OBJECT; + private int _xmltype = XMLTYPE; + private String _name = null; + private String _xmlname = null; + private String _xmlnamespace = null; + private boolean _isXMLRootElement = false; + private HashMap _fieldMap = new HashMap(); + + /** + * Constructor. + * + * @param type the class that contains XmlType annotation. + * @name the persistent field name that maps to xml column + * @param repo the meta repository. + */ + public XMLClassMetaData(Class type, String name, XMLMappingRepository repos) { + _type = type; + _isXMLRootElement = _type.getAnnotation(XmlRootElement.class) != null; + if (_isXMLRootElement) { + _xmlname = ((XmlRootElement) _type.getAnnotation + (XmlRootElement.class)).name(); + _xmlnamespace = ((XmlRootElement) _type.getAnnotation + (XmlRootElement.class)).namespace(); + } + else { + _xmlname = ((XmlType) _type.getAnnotation + (XmlType.class)).name(); + _xmlnamespace = ((XmlType) _type.getAnnotation + (XmlType.class)).namespace(); + _name = name; + } + populateFromReflection(_type, repos); + } + + /** + * Constructor. Supply described type and repository. + * + * @param type the class that contains XmlType annotation. + * @param repo the meta repository. + */ + protected XMLClassMetaData(Class type, XMLMappingRepository repos) { + _type = type; + _isXMLRootElement = _type.getAnnotation(XmlRootElement.class) != null; + if (_isXMLRootElement) { + _xmlname = ((XmlRootElement) _type.getAnnotation + (XmlRootElement.class)).name(); + _xmlnamespace = ((XmlRootElement) _type.getAnnotation + (XmlRootElement.class)).namespace(); + } + else { + _xmlname = ((XmlType) _type.getAnnotation + (XmlType.class)).name(); + _xmlnamespace = ((XmlType) _type.getAnnotation + (XmlType.class)).namespace(); + } + populateFromReflection(_type, repos); + repos.addXMLClassMetaData(type, this); + } + + /** + * Given a class type return true if XmlType annotation exists + * @param type + * @return true if XmlType annotation is present else false. + */ + public static boolean isXMLMapping(Class type) { + return type.isAnnotationPresent(XmlType.class); + } + + public void setName(String name) { + _name = name; + } + + public String getName() { + return _name; + } + + public void setXmlname(String name) { + _xmlname = name; + } + + public String getXmlname() { + return _isXMLRootElement ? null : _xmlname; + } + + public void setXmlnamespace(String name) { + // avoid JAXB XML bind default name + if (!StringUtils.equals(defaultName, name)) + _xmlnamespace = name; + } + + public String getXmlnamespace() { + return _xmlnamespace; + } + + public boolean isXmlRootElement() { + return _isXMLRootElement; + } + + public boolean isXmlElement() { + return false; + } + + public boolean isXmlAttribute() { + return false; + } + + public XMLMapping getFieldMapping(String name) { + return (XMLMapping) _fieldMap.get(name); + } + + public void setType(Class type) { + _type = type; + } + + public Class getType() { + return _type; + } + + public int getTypeCode() { + return _code; + } + + public void setXmltype(int type) { + _xmltype = type; + } + public int getXmltype() { + return _xmltype; + } + + private synchronized void populateFromReflection(Class cls, + XMLMappingRepository repos) { + Member[] members; + if (((XmlAccessorType)cls.getAnnotation(XmlAccessorType.class)).value() + == XmlAccessType.FIELD) + members = cls.getDeclaredFields(); + else + members = cls.getDeclaredMethods(); + for (int i = 0; i < members.length; i++) { + Member member = members[i]; + AnnotatedElement el = (AnnotatedElement) member; + XMLMapping field = null; + if (el.getAnnotation(XmlElement.class) != null) { + String xmlname = el.getAnnotation(XmlElement.class).name(); + // avoid JAXB XML bind default name + if (StringUtils.equals(defaultName, xmlname)) + xmlname = member.getName(); + if (((Field) member).getType(). + isAnnotationPresent(XmlType.class)) { + field = new XMLClassMetaData(((Field) member).getType(), + repos); + field.setXmltype(XMLTYPE); + field.setXmlname(xmlname); + } + else { + field = new XMLMetaData(); + field.setXmltype(ELEMENT); + field.setXmlname(xmlname); + field.setXmlnamespace(el.getAnnotation(XmlElement.class) + .namespace()); + } + } + else if (el.getAnnotation(XmlAttribute.class) != null) { + field = new XMLMetaData(); + field.setXmltype(XMLMetaData.ATTRIBUTE); + String xmlname = el.getAnnotation(XmlAttribute.class).name(); + // avoid JAXB XML bind default name + if (StringUtils.equals(defaultName, xmlname)) + xmlname = member.getName(); + field.setXmlname("@"+xmlname); + field.setXmlnamespace(el.getAnnotation(XmlAttribute.class) + .namespace()); + } + field.setName(member.getName()); + field.setType(((Field) member).getType()); + _fieldMap.put(member.getName(), field); + } + } +} diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMapping.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMapping.java index dbe0ac5f8..7f2c744c6 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMapping.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMapping.java @@ -1,119 +1,119 @@ -/* - * 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.meta; - -import java.io.Serializable; - -/** - * Describe metadata about an xml type. - * - * @author Catalina Wei - * @since 1.0.0 - */ -public interface XMLMapping extends Serializable { - /** - * JAXB XML binding default name - */ - public static final String defaultName = "##default"; - public static final int XMLTYPE = 0; - public static final int ELEMENT = 1; - public static final int ATTRIBUTE = 2; - - /** - * Return true if mapping on an XmlRootElement. - */ - public boolean isXmlRootElement(); - - /** - * Return true if mapping on an XmlElement. - */ - public boolean isXmlElement(); - - /** - * Return true if mapping on an XmlAttribute. - */ - public boolean isXmlAttribute(); - - /** - * Return XMLMapping for a given field. - * @param name the field name. - * @return XMLMapping. - */ - public XMLMapping getFieldMapping(String name); - - /** - * Set type. - */ - public void setType(Class type); - - /** - * Return type. - */ - public Class getType(); - - /** - * Return type code. - */ - public int getTypeCode(); - - /** - * Return the mapping name. - */ - public String getName(); - - /** - * Return xml element tag name or xml attribute name. - */ - public String getXmlname(); - - /** - * Return xml namespace. - */ - public String getXmlnamespace(); - - /** - * Set field name. - * @param name the field name. - */ - public void setName(String name); - - /** - * Set xml element or attribute name. - * @param name the element name or attribute name - */ - public void setXmlname(String name); - - /** - * Set namespace. - * @param namespace - */ - public void setXmlnamespace(String namespace); - - /** - * Set xmltype - * @param type XMLTYPE, ELEMENT, or ATTRIBUTE - */ - public void setXmltype(int type); - - /** - * Return xmltype - * @return xmltype - */ - public int getXmltype(); -} +/* + * 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.meta; + +import java.io.Serializable; + +/** + * Describe metadata about an xml type. + * + * @author Catalina Wei + * @since 1.0.0 + */ +public interface XMLMapping extends Serializable { + /** + * JAXB XML binding default name + */ + public static final String defaultName = "##default"; + public static final int XMLTYPE = 0; + public static final int ELEMENT = 1; + public static final int ATTRIBUTE = 2; + + /** + * Return true if mapping on an XmlRootElement. + */ + public boolean isXmlRootElement(); + + /** + * Return true if mapping on an XmlElement. + */ + public boolean isXmlElement(); + + /** + * Return true if mapping on an XmlAttribute. + */ + public boolean isXmlAttribute(); + + /** + * Return XMLMapping for a given field. + * @param name the field name. + * @return XMLMapping. + */ + public XMLMapping getFieldMapping(String name); + + /** + * Set type. + */ + public void setType(Class type); + + /** + * Return type. + */ + public Class getType(); + + /** + * Return type code. + */ + public int getTypeCode(); + + /** + * Return the mapping name. + */ + public String getName(); + + /** + * Return xml element tag name or xml attribute name. + */ + public String getXmlname(); + + /** + * Return xml namespace. + */ + public String getXmlnamespace(); + + /** + * Set field name. + * @param name the field name. + */ + public void setName(String name); + + /** + * Set xml element or attribute name. + * @param name the element name or attribute name + */ + public void setXmlname(String name); + + /** + * Set namespace. + * @param namespace + */ + public void setXmlnamespace(String namespace); + + /** + * Set xmltype + * @param type XMLTYPE, ELEMENT, or ATTRIBUTE + */ + public void setXmltype(int type); + + /** + * Return xmltype + * @return xmltype + */ + public int getXmltype(); +} diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMetaData.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMetaData.java index 60259c8ab..ea9e63b9e 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMetaData.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/XMLMetaData.java @@ -1,111 +1,111 @@ -/* - * 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.meta; - -import org.apache.commons.lang.StringUtils; - -/** - * Contains metadata about an xml element or attribute - * - * @author Catalina Wei - * @since 1.0.0 - */ -public class XMLMetaData implements XMLMapping { - - private String _name; - private String _xmlname = null; - private String _xmlnamespace = null; - private Class _decType = Object.class; - private int _decCode = JavaTypes.OBJECT; - private Class _type = Object.class; - private int _code = JavaTypes.OBJECT; - private int _xmltype; - - public XMLMetaData() { - } - - public Class getType() { - return (_type == null) ? _decType : _type; - } - - public void setType(Class type) { - _type = type; - if (type != null) - setTypeCode(JavaTypes.getTypeCode(type)); - } - - public int getTypeCode() { - return (_type == null) ? _decCode : _code; - } - - // set JavaTypes code - public void setTypeCode(int code) { - _code = code; - } - - public void setName(String name) { - _name = name; - } - - public String getName() { - return _name; - } - - public void setXmlname(String name) { - _xmlname = name; - } - - public String getXmlname() { - return _xmlname; - } - - public void setXmlnamespace(String name) { - // avoid JAXB XML bind default name - if (!StringUtils.equals(defaultName, name)) - _xmlnamespace = name; - } - - public String getXmlnamespace() { - return _xmlnamespace; - } - - public void setXmltype(int type) { - _xmltype = type; - } - - public int getXmltype() { - return _xmltype; - } - - public boolean isXmlRootElement() { - return false; - } - - public boolean isXmlElement() { - return _xmltype == ELEMENT; - } - - public boolean isXmlAttribute() { - return _xmltype == ATTRIBUTE; - } - - public XMLMapping getFieldMapping(String name) { - return null; - } -} +/* + * 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.meta; + +import org.apache.commons.lang.StringUtils; + +/** + * Contains metadata about an xml element or attribute + * + * @author Catalina Wei + * @since 1.0.0 + */ +public class XMLMetaData implements XMLMapping { + + private String _name; + private String _xmlname = null; + private String _xmlnamespace = null; + private Class _decType = Object.class; + private int _decCode = JavaTypes.OBJECT; + private Class _type = Object.class; + private int _code = JavaTypes.OBJECT; + private int _xmltype; + + public XMLMetaData() { + } + + public Class getType() { + return (_type == null) ? _decType : _type; + } + + public void setType(Class type) { + _type = type; + if (type != null) + setTypeCode(JavaTypes.getTypeCode(type)); + } + + public int getTypeCode() { + return (_type == null) ? _decCode : _code; + } + + // set JavaTypes code + public void setTypeCode(int code) { + _code = code; + } + + public void setName(String name) { + _name = name; + } + + public String getName() { + return _name; + } + + public void setXmlname(String name) { + _xmlname = name; + } + + public String getXmlname() { + return _xmlname; + } + + public void setXmlnamespace(String name) { + // avoid JAXB XML bind default name + if (!StringUtils.equals(defaultName, name)) + _xmlnamespace = name; + } + + public String getXmlnamespace() { + return _xmlnamespace; + } + + public void setXmltype(int type) { + _xmltype = type; + } + + public int getXmltype() { + return _xmltype; + } + + public boolean isXmlRootElement() { + return false; + } + + public boolean isXmlElement() { + return _xmltype == ELEMENT; + } + + public boolean isXmlAttribute() { + return _xmltype == ATTRIBUTE; + } + + public XMLMapping getFieldMapping(String name) { + return null; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Customer.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Customer.java index 0599a6b88..e3f4e0e73 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Customer.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Customer.java @@ -1,131 +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 orders = new ArrayList(); - - 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 getOrders() { - return orders; - } - public void setOrders(Collection 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; - } -} +/* + * 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 orders = new ArrayList(); + + 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 getOrders() { + return orders; + } + public void setOrders(Collection 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; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/EAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/EAddress.java index a402817b4..23878beb0 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/EAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/EAddress.java @@ -1,75 +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; - } - -} +/* + * 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; + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Order.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Order.java index c0f2643ea..f4c640630 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Order.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/entities/Order.java @@ -1,98 +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; - } -} +/* + * 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; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/query/TestXMLCustomerOrder.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/query/TestXMLCustomerOrder.java index d73062ad2..7df58d4ef 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/query/TestXMLCustomerOrder.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/query/TestXMLCustomerOrder.java @@ -1,293 +1,293 @@ -/* - * 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
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(); - } -} +/* + * 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
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(); + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java index d84e1ca80..cfd53c7f9 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java @@ -1,142 +1,142 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs -// See http://java.sun.com/xml/jaxb -// 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; - -/** - *

Java class for Address complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <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>
- * 
- * - * - */ - -@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 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. - * - *

- * 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 set method for the street property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getStreet().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link String } - * - * - */ - public List getStreet() { - if (street == null) { - street = new ArrayList(); - } - 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(); - } -} +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs +// See http://java.sun.com/xml/jaxb +// 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; + +/** + *

Java class for Address complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <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>
+ * 
+ * + * + */ + +@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 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. + * + *

+ * 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 set method for the street property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getStreet().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getStreet() { + if (street == null) { + street = new ArrayList(); + } + 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(); + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java index 31999bee3..2ce606776 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java @@ -1,111 +1,111 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs -// See http://java.sun.com/xml/jaxb -// 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; - - -/** - *

Java class for CAN_Address complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <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>
- * 
- * - * - */ -@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(); - } -} +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs +// See http://java.sun.com/xml/jaxb +// 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; + + +/** + *

Java class for CAN_Address complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <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>
+ * 
+ * + * + */ +@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(); + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java index eb178e421..e735f5d01 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java @@ -1,111 +1,111 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs -// See http://java.sun.com/xml/jaxb -// 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; - - -/** - *

Java class for GBR_Address complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <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>
- * 
- * - * - */ -@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(); - } -} +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs +// See http://java.sun.com/xml/jaxb +// 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; + + +/** + *

Java class for GBR_Address complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <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>
+ * 
+ * + * + */ +@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(); + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java index 60454ef8f..d05429213 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java @@ -1,122 +1,122 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs -// See http://java.sun.com/xml/jaxb -// 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. - *

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 createAddrUSA(USAAddress value) { - return new JAXBElement(_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 createAddrCAN(CANAddress value) { - return new JAXBElement(_AddrCAN_QNAME, CANAddress.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Address }{@code >}} - * - */ - @XmlElementDecl(namespace = "", name = "MailAddress") - public JAXBElement

createMailAddress(Address value) { - return new JAXBElement
(_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 createAddrGBR(GBRAddress value) { - return new JAXBElement(_AddrGBR_QNAME, GBRAddress.class, null, value); - } - -} +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs +// See http://java.sun.com/xml/jaxb +// 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. + *

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 createAddrUSA(USAAddress value) { + return new JAXBElement(_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 createAddrCAN(CANAddress value) { + return new JAXBElement(_AddrCAN_QNAME, CANAddress.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Address }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "MailAddress") + public JAXBElement

createMailAddress(Address value) { + return new JAXBElement
(_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 createAddrGBR(GBRAddress value) { + return new JAXBElement(_AddrGBR_QNAME, GBRAddress.class, null, value); + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java index 063e0ae1f..3b3f540d7 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java @@ -1,46 +1,46 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs -// See http://java.sun.com/xml/jaxb -// 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; - - -/** - *

Java class for ShortAddress complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <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>
- * 
- * - * - */ -@XmlRootElement -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "ShortAddress") -public class ShortAddress - extends Address -{ - - -} +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs +// See http://java.sun.com/xml/jaxb +// 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; + + +/** + *

Java class for ShortAddress complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <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>
+ * 
+ * + * + */ +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ShortAddress") +public class ShortAddress + extends Address +{ + + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java index 4f1ba759c..23604ee38 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java @@ -1,103 +1,103 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs -// See http://java.sun.com/xml/jaxb -// 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; - - -/** - *

Java class for USA_Address complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <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>
- * 
- * - * - */ -@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(); - } -} +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs +// See http://java.sun.com/xml/jaxb +// 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; + + +/** + *

Java class for USA_Address complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <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>
+ * 
+ * + * + */ +@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(); + } +}