Author: epbernard
Date: 2008-06-10 09:48:38 -0400 (Tue, 10 Jun 2008)
New Revision: 14758
Modified:
annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
Log:
ANN-742 mappedBy side should not generate the PF and FK: already done form the other side
Modified: annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2008-06-09
22:36:38 UTC (rev 14757)
+++ annotations/trunk/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2008-06-10
13:48:38 UTC (rev 14758)
@@ -73,7 +73,7 @@
else {
referencedEntityName = targetEntity.getName();
}
- value.setReferencedEntityName( referencedEntityName );
+ value.setReferencedEntityName( referencedEntityName );
AnnotationBinder.defineFetchingStrategy( value, inferredData.getProperty() );
//value.setFetchMode( fetchMode );
value.setCascadeDeleteEnabled( cascadeOnDelete );
@@ -153,7 +153,7 @@
}
if ( otherSideJoin != null ) {
//@OneToOne @JoinTable
- Join mappedByJoin = buildJoin(
+ Join mappedByJoin = buildJoinFromMappedBySide(
(PersistentClass) persistentClasses.get( ownerEntity ), otherSideProperty,
otherSideJoin
);
ManyToOne manyToOne = new ManyToOne( mappedByJoin.getTable() );
@@ -216,7 +216,7 @@
}
//dirty dupe of EntityBinder.bindSecondaryTable
- private Join buildJoin(PersistentClass persistentClass, Property otherSideProperty, Join
originalJoin) {
+ private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property
otherSideProperty, Join originalJoin) {
Join join = new Join();
join.setPersistentClass( persistentClass );
@@ -247,8 +247,9 @@
copy.setDefaultValue( column.getDefaultValue() );
key.addColumn( copy );
}
- join.createPrimaryKey();
- join.createForeignKey();
+ //from the mappedBy side we should not create the PK nor the FK, this is handled from
te other side
+ //join.createPrimaryKey();
+ //join.createForeignKey();
persistentClass.addJoin( join );
return join;
}
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-09
22:36:38 UTC (rev 14757)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-10
13:48:38 UTC (rev 14758)
@@ -30,7 +30,7 @@
log.debug(s);
}
String expectedMappingTableSql = "create table personAddress (address_id
numeric(19,0) null, " +
- "person_id numeric(19,0) not null, primary key (address_id))";
+ "person_id numeric(19,0) not null, primary key (person_id))";
assertEquals("Wrong SQL", expectedMappingTableSql, schema[2]);
} catch (Exception e) {
fail(e.getMessage());