From: <one...@us...> - 2003-01-27 07:08:12
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/map In directory sc8-pr-cvs1:/tmp/cvs-serv23693/hibernate/map Modified Files: Collection.java Component.java RootClass.java Table.java Value.java Log Message: fixed a bug setting up id generators Index: Collection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Collection.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Collection.java 25 Dec 2002 04:16:36 -0000 1.52 --- Collection.java 27 Jan 2003 07:08:09 -0000 1.53 *************** *** 139,143 **** if ( "key".equals(name) || "generated-key".equals(name) ) { key = new Value(subnode, null, DEFAULT_KEY_COLUMN_NAME, isOneToMany, table, root); ! if (!toplevel) key.setType( owner.getIdentifier().getType() ); if ( key.getType().returnedClass().isArray() ) throw new MappingException( "illegal use of an array as an identifier (arrays don't reimplement equals)" --- 139,148 ---- if ( "key".equals(name) || "generated-key".equals(name) ) { key = new Value(subnode, null, DEFAULT_KEY_COLUMN_NAME, isOneToMany, table, root); ! if (!toplevel) { ! key.setType( owner.getIdentifier().getType() ); ! } ! else { ! key.makeIdentifier(subnode, root); ! } if ( key.getType().returnedClass().isArray() ) throw new MappingException( "illegal use of an array as an identifier (arrays don't reimplement equals)" Index: Component.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Component.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Component.java 22 Jan 2003 13:06:39 -0000 1.37 --- Component.java 27 Jan 2003 07:08:09 -0000 1.38 *************** *** 53,57 **** public Component(Node node, Class reflectedClass, String path, PersistentClass owner, boolean isNullable, Table table, Root root) throws MappingException { ! super(node, root); setTable(table); Node classNode = node.getAttributes().getNamedItem("class"); --- 53,57 ---- public Component(Node node, Class reflectedClass, String path, PersistentClass owner, boolean isNullable, Table table, Root root) throws MappingException { ! setTable(table); Node classNode = node.getAttributes().getNamedItem("class"); Index: RootClass.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/RootClass.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** RootClass.java 22 Jan 2003 13:06:39 -0000 1.57 --- RootClass.java 27 Jan 2003 07:08:09 -0000 1.58 *************** *** 115,128 **** } - //DISCRIMINATOR (deprecated; to support old DTD) - Node discriminatorColumnNode = atts.getNamedItem("discriminator"); - if (discriminatorColumnNode!=null) { - discriminator = new Value( Hibernate.STRING, table, discriminatorColumnNode.getNodeValue() ); - polymorphic=true; - } - else { - discriminator = null; - polymorphic=false; - } //MUTABLE Node mutableNode = atts.getNamedItem("mutable"); --- 115,118 ---- *************** *** 154,157 **** --- 144,148 ---- "illegal use of an array as an identifier (arrays don't reimplement equals)" ); + identifier.makeIdentifier(subnode, root); } else if ( "composite-id".equals(name) ) { *************** *** 166,169 **** --- 157,161 ---- identifierProperty = new Property(subnode, identifier, root); } + identifier.makeIdentifier(subnode, root); } else if ( "version".equals(name) || "timestamp".equals(name) ) { Index: Table.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Table.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Table.java 26 Dec 2002 03:35:07 -0000 1.34 --- Table.java 27 Jan 2003 07:08:09 -0000 1.35 *************** *** 116,121 **** pkname = ( (Column) primaryKey.getColumnIterator().next() ).getName(); } ! else createIdentity = false; Iterator iter = columnIterator(); --- 116,122 ---- pkname = ( (Column) primaryKey.getColumnIterator().next() ).getName(); } ! else { createIdentity = false; + } Iterator iter = columnIterator(); Index: Value.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Value.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** Value.java 22 Jan 2003 13:06:39 -0000 1.46 --- Value.java 27 Jan 2003 07:08:09 -0000 1.47 *************** *** 55,62 **** this.table = table; } - - protected Value() {} ! protected Value(Node node, Root root) throws MappingException { //GENERATOR NodeList list = node.getChildNodes(); --- 55,62 ---- this.table = table; } ! protected Value() {} ! ! void makeIdentifier(Node node, Root root) throws MappingException { //GENERATOR NodeList list = node.getChildNodes(); *************** *** 66,73 **** try { generator = root.createIDGenerator(subnode); ! } catch (Exception e) { throw new MappingException( "Error creating ID generator",e); } ! if (table!=null) table.setIdentifierGenerator(generator); } } --- 66,74 ---- try { generator = root.createIDGenerator(subnode); ! } ! catch (Exception e) { throw new MappingException( "Error creating ID generator",e); } ! table.setIdentifierGenerator(generator); } } *************** *** 77,92 **** } - public Value(Type type, Table table, String columnName) { - this.type = type; - Column column = new Column(type, 0); - column.setName(columnName); - table.addColumn(column); - addColumn(column); - } - //Does _not_ automatically make a column if none is specifed by XML public Value(Node node, String path, boolean isNullable, Table table, Root root) throws MappingException { ! this(node, root); ! this.table = table; NamedNodeMap atts = node.getAttributes(); --- 78,85 ---- } //Does _not_ automatically make a column if none is specifed by XML public Value(Node node, String path, boolean isNullable, Table table, Root root) throws MappingException { ! ! this.table=table; NamedNodeMap atts = node.getAttributes(); |