From: <one...@us...> - 2003-04-03 12:34:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id In directory sc8-pr-cvs1:/tmp/cvs-serv28961/hibernate/id Modified Files: ForeignGenerator.java IdentifierGeneratorFactory.java Log Message: * improved foreign id-generator * fixed a bug with long path expressions ending in elements or indices in where clause Index: ForeignGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id/ForeignGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ForeignGenerator.java 29 Mar 2003 04:20:18 -0000 1.1 --- ForeignGenerator.java 3 Apr 2003 12:34:28 -0000 1.2 *************** *** 20,24 **** */ public class ForeignGenerator implements IdentifierGenerator, Configurable { ! private String propertyName; --- 20,24 ---- */ public class ForeignGenerator implements IdentifierGenerator, Configurable { ! private String propertyName; *************** *** 32,36 **** .getClassMetadata( object.getClass() ) .getPropertyValue(object, propertyName); ! return session.getEntityIdentifierIfNotUnsaved(associatedObject); } --- 32,43 ---- .getClassMetadata( object.getClass() ) .getPropertyValue(object, propertyName); ! //return session.getEntityIdentifierIfNotUnsaved(associatedObject); ! Serializable id = session.save(associatedObject); ! if ( session.contains(object) ) { ! //abort the save (the object is already saved by a circular cascade) ! return IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR; ! //throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association"); ! } ! return id; } Index: IdentifierGeneratorFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id/IdentifierGeneratorFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierGeneratorFactory.java 29 Mar 2003 04:20:18 -0000 1.3 --- IdentifierGeneratorFactory.java 3 Apr 2003 12:34:29 -0000 1.4 *************** *** 15,19 **** * Factory methods for <tt>IdentifierGenerator</tt> framework */ ! public class IdentifierGeneratorFactory { // unhappy about this being public ... is there a better way? --- 15,19 ---- * Factory methods for <tt>IdentifierGenerator</tt> framework */ ! public final class IdentifierGeneratorFactory { // unhappy about this being public ... is there a better way? *************** *** 34,37 **** --- 34,39 ---- private static final HashMap idgenerators = new HashMap(); + + public static final String SHORT_CIRCUIT_INDICATOR = new String(); static { idgenerators.put("uuid.hex", UUIDHexGenerator.class); *************** *** 84,87 **** --- 86,91 ---- } } + + private IdentifierGeneratorFactory() {} //cannot be instantiated } |