Hibernate SVN: r12674 - tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:59:17 -0400 (Tue, 03 Jul 2007)
New Revision: 12674
Added:
core/tags/JBOSS_EAP_3_2_4_SP1_CP01/jdbc/
Removed:
tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/jdbc/
Log:
migrating core/tags/JBOSS_EAP_3_2_4_SP1_CP01 tag to new layout
Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP01/jdbc (from rev 12673, tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/jdbc)
17 years, 6 months
Hibernate SVN: r12673 - tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:58:41 -0400 (Tue, 03 Jul 2007)
New Revision: 12673
Added:
core/tags/JBOSS_EAP_3_2_4_SP1_CP01/grammar/
Removed:
tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/grammar/
Log:
migrating core/tags/JBOSS_EAP_3_2_4_SP1_CP01 tag to new layout
Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP01/grammar (from rev 12672, tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/grammar)
17 years, 6 months
Hibernate SVN: r12672 - tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:58:04 -0400 (Tue, 03 Jul 2007)
New Revision: 12672
Added:
core/tags/JBOSS_EAP_3_2_4_SP1_CP01/etc/
Removed:
tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/etc/
Log:
migrating core/tags/JBOSS_EAP_3_2_4_SP1_CP01 tag to new layout
Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP01/etc (from rev 12671, tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/etc)
17 years, 6 months
Hibernate SVN: r12671 - tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:57:19 -0400 (Tue, 03 Jul 2007)
New Revision: 12671
Added:
core/tags/JBOSS_EAP_3_2_4_SP1_CP01/eg/
Removed:
tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/eg/
Log:
migrating core/tags/JBOSS_EAP_3_2_4_SP1_CP01 tag to new layout
Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP01/eg (from rev 12670, tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/eg)
17 years, 6 months
Hibernate SVN: r12670 - tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:56:45 -0400 (Tue, 03 Jul 2007)
New Revision: 12670
Added:
core/tags/JBOSS_EAP_3_2_4_SP1_CP01/doc/
Removed:
tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/doc/
Log:
migrating core/tags/JBOSS_EAP_3_2_4_SP1_CP01 tag to new layout
Copied: core/tags/JBOSS_EAP_3_2_4_SP1_CP01/doc (from rev 12669, tags/JBOSS_EAP_3_2_4_SP1_CP01/Hibernate3/doc)
17 years, 6 months
Hibernate SVN: r12669 - core/tags.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:55:37 -0400 (Tue, 03 Jul 2007)
New Revision: 12669
Added:
core/tags/JBOSS_EAP_3_2_4_SP1_CP01/
Log:
migrating core/tags/JBOSS_EAP_3_2_4_SP1_CP01 tag to new layout
17 years, 6 months
Hibernate SVN: r12668 - tags.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:51:31 -0400 (Tue, 03 Jul 2007)
New Revision: 12668
Added:
tags/JBOSS_EAP_3_2_4_SP1_CP01/
Removed:
tags/JBOSS_EAP_3_2_4_SP1_CP01@HEAD/
Log:
fixed naming
Copied: tags/JBOSS_EAP_3_2_4_SP1_CP01 (from rev 12667, tags/JBOSS_EAP_3_2_4_SP1_CP01@HEAD)
17 years, 6 months
Hibernate SVN: r12667 - tags.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-07-03 12:50:13 -0400 (Tue, 03 Jul 2007)
New Revision: 12667
Added:
tags/JBOSS_EAP_3_2_4_SP1_CP01@HEAD/
Log:
restoring tag
Copied: tags/JBOSS_EAP_3_2_4_SP1_CP01@HEAD (from rev 11860, tags/JBOSS_EAP_3_2_4_SP1_CP01)
17 years, 6 months
Hibernate SVN: r12666 - in trunk/HibernateExt/annotations/src: test/org/hibernate/test/annotations/onetoone and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-03 12:26:31 -0400 (Tue, 03 Jul 2007)
New Revision: 12666
Added:
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/OneToOneErrorTest.java
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/Show.java
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/ShowDescription.java
Modified:
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java
Log:
ANN-613 Fail properly when mappedBy is wrong
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2007-07-03 15:20:03 UTC (rev 12665)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/OneToOneSecondPass.java 2007-07-03 16:26:31 UTC (rev 12666)
@@ -132,6 +132,13 @@
+ StringHelper.qualify( value.getReferencedEntityName(), mappedBy )
);
}
+ if (otherSideProperty == null) {
+ throw new AnnotationException(
+ "Unknown mappedBy in: " + StringHelper.qualify( ownerEntity, ownerProperty )
+ + ", referenced property unknown: "
+ + StringHelper.qualify( value.getReferencedEntityName(), mappedBy )
+ );
+ }
if ( otherSideProperty.getValue() instanceof OneToOne ) {
propertyHolder.addProperty( prop );
}
Added: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/OneToOneErrorTest.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/OneToOneErrorTest.java (rev 0)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/OneToOneErrorTest.java 2007-07-03 16:26:31 UTC (rev 12666)
@@ -0,0 +1,27 @@
+//$Id$
+package org.hibernate.test.annotations.onetoone;
+
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.test.annotations.IncorrectEntity;
+import org.hibernate.SessionFactory;
+import org.hibernate.AnnotationException;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class OneToOneErrorTest extends junit.framework.TestCase {
+ public void testWrongOneToOne() throws Exception {
+ AnnotationConfiguration cfg = new AnnotationConfiguration();
+ cfg.addAnnotatedClass( Show.class )
+ .addAnnotatedClass( ShowDescription.class );
+ cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
+ try {
+ SessionFactory sf = cfg.buildSessionFactory();
+ fail( "Wrong mappedBy does not fail property" );
+ }
+ catch (AnnotationException e) {
+ //success
+ }
+ }
+}
\ No newline at end of file
Added: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/Show.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/Show.java (rev 0)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/Show.java 2007-07-03 16:26:31 UTC (rev 12666)
@@ -0,0 +1,33 @@
+//$Id$
+package org.hibernate.test.annotations.onetoone;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Show {
+ @Id
+ private Integer id;
+ @OneToOne() private ShowDescription description;
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public ShowDescription getDescription() {
+ return description;
+ }
+
+ public void setDescription(ShowDescription description) {
+ this.description = description;
+ }
+}
Added: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/ShowDescription.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/ShowDescription.java (rev 0)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/onetoone/ShowDescription.java 2007-07-03 16:26:31 UTC (rev 12666)
@@ -0,0 +1,34 @@
+//$Id$
+package org.hibernate.test.annotations.onetoone;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class ShowDescription {
+ @Id
+ private Integer id;
+ @OneToOne(mappedBy = "wrongProperty")
+ private Show show;
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Show getShow() {
+ return show;
+ }
+
+ public void setShow(Show show) {
+ this.show = show;
+ }
+}
17 years, 6 months
Hibernate SVN: r12665 - in trunk/HibernateExt/annotations/src: java/org/hibernate/cfg and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-07-03 11:20:03 -0400 (Tue, 03 Jul 2007)
New Revision: 12665
Added:
trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/NaturalId.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/Citizen.java
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/State.java
Removed:
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexSecondPass.java
Modified:
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java
trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/Version.java
Log:
ANN-122 add @NaturalId annotation (Nicol?\195?\161s Lichtmaier)
Added: trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/NaturalId.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/NaturalId.java (rev 0)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/annotations/NaturalId.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -0,0 +1,22 @@
+package org.hibernate.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+
+/**
+ * This specifies that a property is part of the natural id of the entity.
+ *
+ * @author Nicol�s Lichtmaier
+ */
+@Target( { METHOD, FIELD } )
+@Retention( RUNTIME )
+public @interface NaturalId {
+ /**
+ * If this natural id component is mutable or not.
+ */
+ boolean mutable() default false;
+}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-07-03 13:24:52 UTC (rev 12664)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/AnnotationBinder.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -76,6 +76,7 @@
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.MapKeyManyToMany;
+import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.OnDelete;
@@ -1597,6 +1598,20 @@
}
}
}
+
+ NaturalId naturalIdAnn = property.getAnnotation( NaturalId.class );
+ if(naturalIdAnn != null)
+ {
+ if(joinColumns != null) {
+ for ( Ejb3Column column : joinColumns ) {
+ column.addUniqueKey("_UniqueKey", inSecondPass);
+ }
+ } else {
+ for ( Ejb3Column column : columns ) {
+ column.addUniqueKey("_UniqueKey", inSecondPass);
+ }
+ }
+ }
}
//TODO move that to collection binder?
@@ -1880,7 +1895,7 @@
//binder.setCascade(cascadeStrategy);
if ( isIdentifierMapper ) {
binder.setInsertable( false );
- binder.setInsertable( false );
+ binder.setUpdatable( false );
}
else {
binder.setInsertable( columns[0].isInsertable() );
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java 2007-07-03 13:24:52 UTC (rev 12664)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3Column.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -431,7 +431,12 @@
public void addIndex(Index index, boolean inSecondPass) {
if ( index == null ) return;
- IndexSecondPass secondPass = new IndexSecondPass( index.name(), this, mappings );
+ String indexName = index.name();
+ addIndex(indexName, inSecondPass);
+ }
+
+ void addIndex(String indexName, boolean inSecondPass) {
+ IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( indexName, this, mappings, false );
if (inSecondPass) {
secondPass.doSecondPass( mappings.getClasses() );
}
@@ -441,4 +446,16 @@
);
}
}
+
+ void addUniqueKey(String uniqueKeyName, boolean inSecondPass) {
+ IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( uniqueKeyName, this, mappings, true );
+ if (inSecondPass) {
+ secondPass.doSecondPass( mappings.getClasses() );
+ }
+ else {
+ mappings.addSecondPass(
+ secondPass
+ );
+ }
+ }
}
\ No newline at end of file
Copied: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java (from rev 11648, trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexSecondPass.java)
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java (rev 0)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -0,0 +1,81 @@
+//$Id$
+package org.hibernate.cfg;
+
+import java.util.Map;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.MappingException;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IndexOrUniqueKeySecondPass implements SecondPass {
+ private Table table;
+ private final String indexName;
+ private final String[] columns;
+ private final ExtendedMappings mappings;
+ private final Ejb3Column column;
+ private final boolean unique;
+
+ /**
+ * Build an index
+ */
+ public IndexOrUniqueKeySecondPass(Table table, String indexName, String[] columns, ExtendedMappings mappings) {
+ this.table = table;
+ this.indexName = indexName;
+ this.columns = columns;
+ this.mappings = mappings;
+ this.column = null;
+ this.unique = false;
+ }
+
+ /**
+ * Build an index
+ */
+ public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, ExtendedMappings mappings) {
+ this(indexName, column, mappings, false);
+ }
+
+ /**
+ * Build an index if unique is false or a Unique Key if unique is true
+ */
+ public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column,
+ ExtendedMappings mappings, boolean unique) {
+ this.indexName = indexName;
+ this.column = column;
+ this.columns = null;
+ this.mappings = mappings;
+ this.unique = unique;
+ }
+
+ public void doSecondPass(Map persistentClasses) throws MappingException {
+ if ( columns != null ) {
+ for ( String columnName : columns ) {
+ addConstraintToColumn( columnName );
+ }
+ }
+ if ( column != null ) {
+ this.table = column.getTable();
+ addConstraintToColumn( mappings.getLogicalColumnName( column.getName(), table ) );
+ }
+ }
+
+ private void addConstraintToColumn(String columnName) {
+ Column column = table.getColumn(
+ new Column(
+ mappings.getPhysicalColumnName( columnName, table )
+ )
+ );
+ if ( column == null ) {
+ throw new AnnotationException(
+ "@Index references a unknown column: " + columnName
+ );
+ }
+ if(unique)
+ table.getOrCreateUniqueKey( indexName ).addColumn( column );
+ else
+ table.getOrCreateIndex( indexName ).addColumn( column );
+ }
+}
Property changes on: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexSecondPass.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexSecondPass.java 2007-07-03 13:24:52 UTC (rev 12664)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/IndexSecondPass.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -1,61 +0,0 @@
-//$Id$
-package org.hibernate.cfg;
-
-import java.util.Map;
-
-import org.hibernate.AnnotationException;
-import org.hibernate.MappingException;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.Table;
-
-/**
- * @author Emmanuel Bernard
- */
-public class IndexSecondPass implements SecondPass {
- private Table table;
- private final String indexName;
- private final String[] columns;
- private final ExtendedMappings mappings;
- private final Ejb3Column column;
-
- public IndexSecondPass(Table table, String indexName, String[] columns, ExtendedMappings mappings) {
- this.table = table;
- this.indexName = indexName;
- this.columns = columns;
- this.mappings = mappings;
- this.column = null;
- }
-
- public IndexSecondPass(String indexName, Ejb3Column column, ExtendedMappings mappings) {
- this.indexName = indexName;
- this.column = column;
- this.columns = null;
- this.mappings = mappings;
- }
-
- public void doSecondPass(Map persistentClasses) throws MappingException {
- if ( columns != null ) {
- for ( String columnName : columns ) {
- addIndexToColumn( columnName );
- }
- }
- if ( column != null ) {
- this.table = column.getTable();
- addIndexToColumn( mappings.getLogicalColumnName( column.getName(), table ) );
- }
- }
-
- private void addIndexToColumn(String columnName) {
- Column column = table.getColumn(
- new Column(
- mappings.getPhysicalColumnName( columnName, table )
- )
- );
- if ( column == null ) {
- throw new AnnotationException(
- "@Index references a unknown column: " + columnName
- );
- }
- table.getOrCreateIndex( indexName ).addColumn( column );
- }
-}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java 2007-07-03 13:24:52 UTC (rev 12664)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/PropertyBinder.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -10,6 +10,7 @@
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.annotations.OptimisticLock;
+import org.hibernate.annotations.NaturalId;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.PropertyHolder;
@@ -153,6 +154,15 @@
prop.setGeneration( PropertyGeneration.parse( generated.toString().toLowerCase() ) );
}
}
+ NaturalId naturalId = property != null ?
+ property.getAnnotation( NaturalId.class ) :
+ null;
+ if ( naturalId != null ) {
+ if ( !naturalId.mutable() ) {
+ updatable = false;
+ }
+ prop.setNaturalIdentifier( true );
+ }
prop.setInsertable( insertable );
prop.setUpdateable( updatable );
OptimisticLock lockAnn = property != null ?
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java 2007-07-03 13:24:52 UTC (rev 12664)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -15,7 +15,7 @@
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
-import org.hibernate.cfg.IndexSecondPass;
+import org.hibernate.cfg.IndexOrUniqueKeySecondPass;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.DependantValue;
@@ -360,7 +360,7 @@
for ( Index index : indexes ) {
//no need to handle inSecondPass here since it is only called from EntityBinder
mappings.addSecondPass(
- new IndexSecondPass( hibTable, index.name(), index.columnNames(), mappings )
+ new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnNames(), mappings )
);
}
}
Modified: trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/Version.java
===================================================================
--- trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/Version.java 2007-07-03 13:24:52 UTC (rev 12664)
+++ trunk/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/Version.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -8,7 +8,7 @@
* @author Emmanuel Bernard
*/
public class Version {
- public static final String VERSION = "3.3.0.GA";
+ public static final String VERSION = "3.3.1.GA";
private static Log log = LogFactory.getLog( Version.class );
static {
Added: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/Citizen.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/Citizen.java (rev 0)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/Citizen.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -0,0 +1,67 @@
+//$Id$
+package org.hibernate.test.annotations.naturalid;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.annotations.NaturalId;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Citizen {
+ @Id
+ @GeneratedValue
+ private Integer id;
+ private String firstname;
+ private String lastname;
+ @NaturalId
+ @ManyToOne
+ private State state;
+ @NaturalId
+ private String ssn;
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ public String getSsn() {
+ return ssn;
+ }
+
+ public void setSsn(String ssn) {
+ this.ssn = ssn;
+ }
+}
Added: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java (rev 0)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -0,0 +1,45 @@
+//$Id$
+package org.hibernate.test.annotations.naturalid;
+
+import java.util.List;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class NaturalIdTest extends TestCase {
+
+ public void testNaturalId() {
+ Citizen c = new Citizen();
+ c.setFirstname( "Emmanuel" );
+ c.setLastname( "Bernard" );
+ c.setSsn( "1234" );
+ State ste = new State();
+ ste.setName( "Ile de France");
+ c.setState( ste);
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( ste );
+ s.persist( c );
+ s.flush();
+ s.clear();
+ List results = s.createCriteria( Citizen.class )
+ .add( Restrictions.naturalId().set( "ssn", "1234" ).set( "state", ste ) )
+ .list();
+ assertEquals( 1, results.size() );
+
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Citizen.class,
+ State.class
+ };
+ }
+}
Added: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/State.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/State.java (rev 0)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/naturalid/State.java 2007-07-03 15:20:03 UTC (rev 12665)
@@ -0,0 +1,33 @@
+//$Id$
+package org.hibernate.test.annotations.naturalid;
+
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class State {
+ @Id
+ @GeneratedValue
+ private Integer id;
+ private String name;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
17 years, 6 months