Author: aadamchik
Date: Sun Apr 30 10:24:34 2006
New Revision: 398388
URL: http://svn.apache.org/viewcvs?rev=398388&view=rev
Log:
changing attribute processing semantics, so that the properties are grouped by
the attribute type
Added:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeDetail.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaRelationship.java
- copied, changed from r398372,
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractRelationship.java
Removed:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractRelationship.java
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaBasic.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToOne.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToMany.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToOne.java
incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MappingAssertion.java
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Sun Apr 30 10:24:34 2006
@@ -21,16 +21,18 @@
import org.apache.cayenne.jpa.JpaProviderException;
import org.apache.cayenne.jpa.conf.JpaLoaderContext;
import org.apache.cayenne.jpa.map.AccessType;
-import org.apache.cayenne.jpa.map.JpaAbstractRelationship;
import org.apache.cayenne.jpa.map.JpaAttribute;
+import org.apache.cayenne.jpa.map.JpaBasic;
import org.apache.cayenne.jpa.map.JpaColumn;
import org.apache.cayenne.jpa.map.JpaEntity;
import org.apache.cayenne.jpa.map.JpaEntityMap;
+import org.apache.cayenne.jpa.map.JpaManyToMany;
import org.apache.cayenne.jpa.map.JpaManyToOne;
import org.apache.cayenne.jpa.map.JpaNamedQuery;
import org.apache.cayenne.jpa.map.JpaOneToMany;
import org.apache.cayenne.jpa.map.JpaOneToOne;
import org.apache.cayenne.jpa.map.JpaQueryHint;
+import org.apache.cayenne.jpa.map.JpaRelationship;
import org.apache.cayenne.jpa.map.JpaTable;
import org.apache.cayenne.util.BaseTreeVisitor;
import org.apache.cayenne.util.HierarchicalTreeVisitor;
@@ -96,37 +98,32 @@
return visitor;
}
- class JpaAttributeVisitor extends NestedVisitor {
+ // class JpaMany
- JpaAttributeVisitor() {
+ class JpaBasicVisitor extends NestedVisitor {
+
+ JpaBasicVisitor() {
addChildVisitor(JpaColumn.class, new JpaColumnVisitor());
- addChildVisitor(JpaManyToOne.class, new JpaRelationshipVisitor());
- addChildVisitor(JpaOneToOne.class, new JpaRelationshipVisitor());
- addChildVisitor(JpaOneToMany.class, new JpaRelationshipVisitor());
}
@Override
Object createObject(ProjectPath path) {
- JpaAttribute jpaAttribute = (JpaAttribute) path.getObject();
+ JpaBasic jpaBasic = (JpaBasic) path.getObject();
ObjEntity parentCayenneEntity = (ObjEntity) targetPath.getObject();
- if (jpaAttribute.isTransient()) {
+ if (jpaBasic.getParent().isTransient()) {
return null;
}
- else if (jpaAttribute.isRelationship()) {
- ObjRelationship cayenneRelationship = new
ObjRelationship(jpaAttribute
- .getName());
-
- parentCayenneEntity.addRelationship(cayenneRelationship);
- return cayenneRelationship;
- }
else {
- ObjAttribute cayenneAttribute = new
ObjAttribute(jpaAttribute.getName());
- cayenneAttribute.setType(getAttributeType(path,
jpaAttribute.getName())
+ ObjAttribute cayenneAttribute = new ObjAttribute(jpaBasic
+ .getParent()
.getName());
-
cayenneAttribute.setDbAttributeName(jpaAttribute.getColumn().getName());
+ cayenneAttribute.setType(getAttributeType(
+ path,
+ jpaBasic.getParent().getName()).getName());
+
cayenneAttribute.setDbAttributeName(jpaBasic.getColumn().getName());
parentCayenneEntity.addAttribute(cayenneAttribute);
return cayenneAttribute;
@@ -218,7 +215,22 @@
class JpaEntityVisitor extends NestedVisitor {
JpaEntityVisitor() {
- addChildVisitor(JpaAttribute.class, new JpaAttributeVisitor());
+ BaseTreeVisitor attributeVisitor = new BaseTreeVisitor();
+ attributeVisitor.addChildVisitor(
+ JpaManyToOne.class,
+ new JpaRelationshipVisitor());
+ attributeVisitor.addChildVisitor(
+ JpaOneToOne.class,
+ new JpaRelationshipVisitor());
+ attributeVisitor.addChildVisitor(
+ JpaOneToMany.class,
+ new JpaRelationshipVisitor());
+ attributeVisitor.addChildVisitor(
+ JpaManyToMany.class,
+ new JpaRelationshipVisitor());
+ attributeVisitor.addChildVisitor(JpaBasic.class, new
JpaBasicVisitor());
+
+ addChildVisitor(JpaAttribute.class, attributeVisitor);
addChildVisitor(JpaTable.class, new JpaTableVisitor());
addChildVisitor(JpaNamedQuery.class, new JpaNamedQueryVisitor());
}
@@ -239,18 +251,18 @@
@Override
public boolean onStartNode(ProjectPath path) {
+ JpaRelationship relationship = (JpaRelationship) path.getObject();
+
+ ObjEntity cayenneSrcEntity = (ObjEntity) targetPath.getObject();
+ ObjRelationship cayenneRelationship = new
ObjRelationship(relationship
+ .getParent()
+ .getName());
- JpaAbstractRelationship relationship = (JpaAbstractRelationship)
path
- .getObject();
+ cayenneSrcEntity.addRelationship(cayenneRelationship);
JpaEntity jpaTargetEntity = ((JpaEntityMap) path.getRoot())
.entityForClass(relationship.getTargetEntityName());
- ObjRelationship cayenneRelationship = (ObjRelationship) targetPath
- .getObject();
-
- ObjEntity cayenneSrcEntity = (ObjEntity) cayenneRelationship
- .getSourceEntity();
DbEntity cayenneSrcDbEntity = cayenneSrcEntity.getDbEntity();
DbEntity cayenneTargetDbEntity =
cayenneSrcEntity.getDataMap().getDbEntity(
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
Sun Apr 30 10:24:34 2006
@@ -17,7 +17,7 @@
import org.apache.cayenne.jpa.JpaProviderException;
import org.apache.cayenne.jpa.map.AccessType;
-import org.apache.cayenne.jpa.map.JpaAbstractRelationship;
+import org.apache.cayenne.jpa.map.JpaRelationship;
import org.apache.cayenne.jpa.map.JpaAttribute;
import org.apache.cayenne.jpa.map.JpaBasic;
import org.apache.cayenne.jpa.map.JpaColumn;
@@ -69,7 +69,12 @@
abstract class AbstractEntityVisitor extends BaseTreeVisitor {
AbstractEntityVisitor() {
- addChildVisitor(JpaAttribute.class, new AttributeVisitor());
+ BaseTreeVisitor attributeVisitor = new BaseTreeVisitor();
+ attributeVisitor.addChildVisitor(JpaBasic.class, new
BasicVisitor());
+ attributeVisitor.addChildVisitor(JpaManyToOne.class, new
FKVisitor());
+ attributeVisitor.addChildVisitor(JpaOneToOne.class, new
FKVisitor());
+
+ addChildVisitor(JpaAttribute.class, attributeVisitor);
addChildVisitor(JpaId.class, new IdVisitor());
}
@@ -154,33 +159,22 @@
}
}
- final class AttributeVisitor extends BaseTreeVisitor {
+ final class BasicVisitor extends BaseTreeVisitor {
- AttributeVisitor() {
+ BasicVisitor() {
addChildVisitor(JpaColumn.class, new ColumnVisitor());
- addChildVisitor(JpaManyToOne.class, new FKVisitor());
- addChildVisitor(JpaOneToOne.class, new FKVisitor());
}
@Override
public boolean onStartNode(ProjectPath path) {
- JpaAttribute attribute = (JpaAttribute) path.getObject();
-
- if (attribute.isRelationship()) {
- return true;
- }
- else if (attribute.isTransient()) {
- return false;
+ JpaBasic jpaBasic = (JpaBasic) path.getObject();
+ if (jpaBasic.getColumn() == null) {
+ JpaColumn column = new
JpaColumn(AnnotationPrototypes.getColumn());
+ column.setName(jpaBasic.getParent().getName());
+ jpaBasic.setColumn(column);
}
- else {
- if (attribute.getColumn() == null) {
- JpaColumn column = new
JpaColumn(AnnotationPrototypes.getColumn());
- column.setName(attribute.getName());
- attribute.setColumn(column);
- }
- return true;
- }
+ return true;
}
}
@@ -257,8 +251,7 @@
JpaAttribute attribute = (JpaAttribute) path.getObjectParent();
if (attribute.getJoinColumns().isEmpty()) {
- JpaAbstractRelationship relationship =
(JpaAbstractRelationship) path
- .getObject();
+ JpaRelationship relationship = (JpaRelationship)
path.getObject();
if (relationship.isOwner()) {
// JPA Spec, 2.1.8.2 (same for all relationship owners):
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
Sun Apr 30 10:24:34 2006
@@ -30,48 +30,42 @@
*/
public class JpaAttribute {
- public static enum AttributeSemantics {
- BASIC, VERSION, MANY_TO_ONE, ONE_TO_MANY, ONE_TO_ONE, MANY_TO_MANY,
EMBEDDED, TRANSIENT
- }
-
- public static enum AttributeMapping {
- COLUMN, JOIN_COLUMN, JOIN_TABLE
- }
-
- public static enum AttributeType {
- LOB, TEMPORAL, ENUMERATED, MAP_KEY, ORDER_BY
+ public static enum BasicSemantics {
+ VERSION, EMBEDDED, TRANSIENT
}
protected String name;
protected Collection<JpaAttributeOverride> attributeOverrides;
- protected AttributeSemantics semantics;
+ // basic attribute properties
protected JpaBasic basic;
- protected JpaManyToOne manyToOne;
- protected JpaOneToMany oneToMany;
- protected JpaOneToOne oneToOne;
- protected JpaManyToMany manyToMany;
-
- protected AttributeMapping mapping;
+ protected BasicSemantics basicSemantics;
protected JpaColumn column;
- protected Collection<JpaJoinColumn> joinColumns;
- protected JpaJoinTable joinTable;
-
- protected AttributeType type;
protected TemporalType temporal;
protected EnumType enumerated = EnumType.ORDINAL;
protected String mapKey;
protected String orderBy;
+ protected boolean lob;
+
+ // one-step relationship properties
+ protected JpaManyToOne manyToOne;
+ protected JpaOneToMany oneToMany;
+ protected JpaOneToOne oneToOne;
+ protected Collection<JpaJoinColumn> joinColumns;
+
+ // flattened relationship properties
+ protected JpaManyToMany manyToMany;
+ protected JpaJoinTable joinTable;
/**
* Returns true if attribute is one of [EMAIL PROTECTED] JpaManyToMany},
[EMAIL PROTECTED] JpaManyToOne},
* [EMAIL PROTECTED] JpaOneToMany}, [EMAIL PROTECTED] JpaOneToOne}.
*/
public boolean isRelationship() {
- return semantics == AttributeSemantics.MANY_TO_ONE
- || semantics == AttributeSemantics.ONE_TO_MANY
- || semantics == AttributeSemantics.ONE_TO_ONE
- || semantics == AttributeSemantics.MANY_TO_MANY;
+ return manyToOne != null
+ || oneToMany != null
+ || oneToOne != null
+ || manyToMany != null;
}
public String getName() {
@@ -93,16 +87,16 @@
return attributeOverrides;
}
- // **** Semantics properties
-
@TreeNodeChild
public JpaBasic getBasic() {
return basic;
}
public void setBasic(JpaBasic basic) {
- this.semantics = AttributeSemantics.BASIC;
this.basic = basic;
+ if (basic != null) {
+ basic.setParent(this);
+ }
}
@TreeNodeChild
@@ -111,8 +105,10 @@
}
public void setManyToMany(JpaManyToMany manyToMany) {
- this.semantics = AttributeSemantics.MANY_TO_MANY;
this.manyToMany = manyToMany;
+ if (manyToMany != null) {
+ manyToMany.setParent(this);
+ }
}
@TreeNodeChild
@@ -121,8 +117,10 @@
}
public void setManyToOne(JpaManyToOne manyToOne) {
- this.semantics = AttributeSemantics.MANY_TO_ONE;
this.manyToOne = manyToOne;
+ if (manyToOne != null) {
+ manyToOne.setParent(this);
+ }
}
@TreeNodeChild
@@ -131,8 +129,10 @@
}
public void setOneToMany(JpaOneToMany oneToMany) {
- this.semantics = AttributeSemantics.ONE_TO_MANY;
this.oneToMany = oneToMany;
+ if (oneToMany != null) {
+ oneToMany.setParent(this);
+ }
}
@TreeNodeChild
@@ -141,85 +141,80 @@
}
public void setOneToOne(JpaOneToOne oneToOne) {
- this.semantics = AttributeSemantics.ONE_TO_ONE;
this.oneToOne = oneToOne;
+ if (oneToOne != null) {
+ oneToOne.setParent(this);
+ }
}
public boolean isVersion() {
- return semantics == AttributeSemantics.VERSION;
+ return basicSemantics == BasicSemantics.VERSION;
}
public void setVersion(boolean version) {
- this.semantics = AttributeSemantics.VERSION;
+ this.basicSemantics = BasicSemantics.VERSION;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
public boolean isEmbedded() {
- return semantics == AttributeSemantics.EMBEDDED;
+ return basicSemantics == BasicSemantics.EMBEDDED;
}
public void setEmbedded(boolean isEmbeddded) {
- this.semantics = isEmbeddded ? AttributeSemantics.EMBEDDED : null;
+ this.basicSemantics = isEmbeddded ? BasicSemantics.EMBEDDED : null;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
public boolean isTransient() {
- return semantics == AttributeSemantics.TRANSIENT;
+ return basicSemantics == BasicSemantics.TRANSIENT;
}
public void setTransient(boolean isTransient) {
- this.semantics = isTransient ? AttributeSemantics.TRANSIENT : null;
+ this.basicSemantics = isTransient ? BasicSemantics.TRANSIENT : null;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
- // **** Mapping properties
-
- @TreeNodeChild
public JpaColumn getColumn() {
return column;
}
public void setColumn(JpaColumn column) {
- this.mapping = AttributeMapping.COLUMN;
this.column = column;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
- @TreeNodeChild(type = JpaJoinColumn.class)
public Collection<JpaJoinColumn> getJoinColumns() {
if (joinColumns == null) {
- joinColumns = new ArrayList<JpaJoinColumn>() {
-
- @Override
- public boolean add(JpaJoinColumn arg0) {
- JpaAttribute.this.mapping = AttributeMapping.JOIN_COLUMN;
- return super.add(arg0);
- }
-
- @Override
- public void add(int arg0, JpaJoinColumn arg1) {
- JpaAttribute.this.mapping = AttributeMapping.JOIN_COLUMN;
- super.add(arg0, arg1);
- }
- };
+ joinColumns = new ArrayList<JpaJoinColumn>();
}
return joinColumns;
}
- @TreeNodeChild
public JpaJoinTable getJoinTable() {
return joinTable;
}
public void setJoinTable(JpaJoinTable joinTable) {
- this.mapping = AttributeMapping.JOIN_TABLE;
this.joinTable = joinTable;
}
- // **** Type properties
-
public boolean isLob() {
- return type == AttributeType.LOB;
+ return lob;
}
public void setLob(boolean isLob) {
- this.type = isLob ? AttributeType.LOB : null;
+ this.lob = isLob;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
/**
@@ -234,8 +229,10 @@
}
public void setEnumerated(EnumType enumerated) {
- this.type = AttributeType.ENUMERATED;
this.enumerated = enumerated;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
public String getMapKey() {
@@ -243,8 +240,10 @@
}
public void setMapKey(String mapKey) {
- this.type = AttributeType.MAP_KEY;
this.mapKey = mapKey;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
public String getOrderBy() {
@@ -252,8 +251,10 @@
}
public void setOrderBy(String orderBy) {
- this.type = AttributeType.ORDER_BY;
this.orderBy = orderBy;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
public TemporalType getTemporal() {
@@ -261,7 +262,9 @@
}
public void setTemporal(TemporalType temporal) {
- this.type = AttributeType.TEMPORAL;
this.temporal = temporal;
+ if (basic == null) {
+ setBasic(new JpaBasic());
+ }
}
}
Added:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeDetail.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeDetail.java?rev=398388&view=auto
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeDetail.java
(added)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeDetail.java
Sun Apr 30 10:24:34 2006
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.cayenne.jpa.map;
+
+public class JpaAttributeDetail {
+
+ protected JpaAttribute parent;
+
+ public JpaAttribute getParent() {
+ return parent;
+ }
+
+ public void setParent(JpaAttribute parent) {
+ this.parent = parent;
+ }
+}
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaBasic.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaBasic.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaBasic.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaBasic.java
Sun Apr 30 10:24:34 2006
@@ -18,7 +18,9 @@
import javax.persistence.Basic;
import javax.persistence.FetchType;
-public class JpaBasic {
+import org.apache.cayenne.util.TreeNodeChild;
+
+public class JpaBasic extends JpaAttributeDetail {
protected FetchType fetch = FetchType.EAGER;
protected boolean optional;
@@ -46,5 +48,16 @@
public void setOptional(boolean optional) {
this.optional = optional;
+ }
+
+ @TreeNodeChild
+ public JpaColumn getColumn() {
+ return parent != null ? parent.getColumn() : null;
+ }
+
+ public void setColumn(JpaColumn column) {
+ if (parent != null) {
+ parent.setColumn(column);
+ }
}
}
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
Sun Apr 30 10:24:34 2006
@@ -17,7 +17,9 @@
import javax.persistence.ManyToMany;
-public class JpaManyToMany extends JpaAbstractRelationship {
+import org.apache.cayenne.util.TreeNodeChild;
+
+public class JpaManyToMany extends JpaRelationship {
public JpaManyToMany() {
@@ -34,5 +36,10 @@
fetch = annotation.fetch();
mappedBy = annotation.mappedBy();
+ }
+
+ @TreeNodeChild
+ public JpaJoinTable getJoinTable() {
+ return parent != null ? parent.getJoinTable() : null;
}
}
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToOne.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToOne.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToOne.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToOne.java
Sun Apr 30 10:24:34 2006
@@ -15,9 +15,13 @@
*/
package org.apache.cayenne.jpa.map;
+import java.util.Collection;
+
import javax.persistence.ManyToOne;
-public class JpaManyToOne extends JpaAbstractRelationship {
+import org.apache.cayenne.util.TreeNodeChild;
+
+public class JpaManyToOne extends JpaRelationship {
protected boolean optional;
@@ -52,5 +56,10 @@
public void setOptional(boolean optional) {
this.optional = optional;
+ }
+
+ @TreeNodeChild(type = JpaJoinColumn.class)
+ public Collection<JpaJoinColumn> getJoinColumns() {
+ return (parent != null) ? parent.getJoinColumns() : null;
}
}
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToMany.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToMany.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToMany.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToMany.java
Sun Apr 30 10:24:34 2006
@@ -15,9 +15,13 @@
*/
package org.apache.cayenne.jpa.map;
+import java.util.Collection;
+
import javax.persistence.OneToMany;
-public class JpaOneToMany extends JpaAbstractRelationship {
+import org.apache.cayenne.util.TreeNodeChild;
+
+public class JpaOneToMany extends JpaRelationship {
public JpaOneToMany() {
@@ -36,4 +40,8 @@
mappedBy = annotation.mappedBy();
}
+ @TreeNodeChild(type = JpaJoinColumn.class)
+ public Collection<JpaJoinColumn> getJoinColumns() {
+ return (parent != null) ? parent.getJoinColumns() : null;
+ }
}
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToOne.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToOne.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToOne.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaOneToOne.java
Sun Apr 30 10:24:34 2006
@@ -15,9 +15,13 @@
*/
package org.apache.cayenne.jpa.map;
+import java.util.Collection;
+
import javax.persistence.OneToOne;
-public class JpaOneToOne extends JpaAbstractRelationship {
+import org.apache.cayenne.util.TreeNodeChild;
+
+public class JpaOneToOne extends JpaRelationship {
protected boolean optional;
@@ -45,5 +49,10 @@
public void setOptional(boolean optional) {
this.optional = optional;
+ }
+
+ @TreeNodeChild(type = JpaJoinColumn.class)
+ public Collection<JpaJoinColumn> getJoinColumns() {
+ return (parent != null) ? parent.getJoinColumns() : null;
}
}
Copied:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaRelationship.java
(from r398372,
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractRelationship.java)
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaRelationship.java?p2=incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaRelationship.java&p1=incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractRelationship.java&r1=398372&r2=398388&rev=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractRelationship.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaRelationship.java
Sun Apr 30 10:24:34 2006
@@ -20,7 +20,7 @@
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
-public abstract class JpaAbstractRelationship {
+public abstract class JpaRelationship extends JpaAttributeDetail {
protected String targetEntityName;
protected FetchType fetch;
Modified:
incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MappingAssertion.java
URL:
http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MappingAssertion.java?rev=398388&r1=398387&r2=398388&view=diff
==============================================================================
---
incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MappingAssertion.java
(original)
+++
incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/MappingAssertion.java
Sun Apr 30 10:24:34 2006
@@ -568,7 +568,6 @@
protected void assertAttributes(List<JpaAttribute> attributes) {
// BASIC
- assertNull(attributes.get(1).getBasic());
assertNotNull(attributes.get(0).getBasic());
assertEquals("attribute1", attributes.get(0).getName());
assertTrue(attributes.get(0).getBasic().isOptional());