|
From: <one...@us...> - 2003-01-02 11:01:54
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping
In directory sc8-pr-cvs1:/tmp/cvs-serv30125/src/net/sf/hibernate/mapping
Modified Files:
Array.java Association.java Collection.java Component.java
IntegerValue.java ManyToOne.java Map.java OneToOne.java
PersistentClass.java Root.java RootClass.java Value.java
Log Message:
changed default unsaved-value
changed 'role' attribute to 'name'
added a new check/exception in delete()
Index: Array.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Array.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Array.java 1 Jan 2003 13:56:13 -0000 1.1.1.1
--- Array.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 32,37 ****
String name = subnode.getNodeName();
! if ( "element".equals(name) || "subcollection".equals(name) ) {
! Type type = Value.getTypeFromXML(subnode, Root.ROOT_ROLE_NAME, root);
elementClass = isPrimitiveArray() ? ( (PrimitiveType) type ).primitiveClass() : type.returnedClass();
}
--- 32,37 ----
String name = subnode.getNodeName();
! if ( "element".equals(name) ) {
! Type type = Value.getTypeFromXML(subnode);
elementClass = isPrimitiveArray() ? ( (PrimitiveType) type ).primitiveClass() : type.returnedClass();
}
Index: Association.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Association.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Association.java 1 Jan 2003 13:56:13 -0000 1.1.1.1
--- Association.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 25,30 ****
// A one-to-one association
! protected Association(Node node, String path, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, path, isNullable, table, root);
joinedFetch = initJoinedFetch(node);
}
--- 25,30 ----
// A one-to-one association
! protected Association(Node node, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, isNullable, table, root);
joinedFetch = initJoinedFetch(node);
}
***************
*** 32,40 ****
// A many-to-one association
protected Association(Node node, String path, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, path, defaultColumnName, isNullable, table, root);
joinedFetch = initJoinedFetch(node);
}
! protected abstract Type typeFromXML(Node node, String path, Root root) throws MappingException;
public abstract void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException;
--- 32,40 ----
// A many-to-one association
protected Association(Node node, String path, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, defaultColumnName, isNullable, table, root);
joinedFetch = initJoinedFetch(node);
}
! protected abstract Type typeFromXML(Node node) throws MappingException;
public abstract void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException;
Index: Collection.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Collection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Collection.java 1 Jan 2003 15:12:52 -0000 1.2
--- Collection.java 2 Jan 2003 11:01:49 -0000 1.3
***************
*** 68,72 ****
NamedNodeMap atts = node.getAttributes();
//ROLENAME
! String barerole = atts.getNamedItem("role").getNodeValue();
role = prefix + Root.ROLE_SEPERATOR + barerole;
--- 68,74 ----
NamedNodeMap atts = node.getAttributes();
//ROLENAME
! Node roleAtt = atts.getNamedItem("name");
! if (roleAtt==null) roleAtt = atts.getNamedItem("role");
! String barerole = roleAtt.getNodeValue();
role = prefix + Root.ROLE_SEPERATOR + barerole;
***************
*** 136,140 ****
if ( "key".equals(name) || "generated-key".equals(name) ) {
! key = new Value(subnode, null, DEFAULT_KEY_COLUMN_NAME, isOneToMany, table, root);
key.setType( owner.getIdentifier().getType() );
if ( key.getType().returnedClass().isArray() ) throw new MappingException(
--- 138,142 ----
if ( "key".equals(name) || "generated-key".equals(name) ) {
! key = new Value(subnode, DEFAULT_KEY_COLUMN_NAME, isOneToMany, table, root);
key.setType( owner.getIdentifier().getType() );
if ( key.getType().returnedClass().isArray() ) throw new MappingException(
***************
*** 143,150 ****
}
else if ( "element".equals(name) ) {
! element = new Value(subnode, Root.ROOT_ROLE_NAME, DEFAULT_ELEMENT_COLUMN_NAME, true, table, root);
! }
! else if ( "subcollection".equals(name) ) {
! element = new Value(subnode, Root.ROOT_ROLE_NAME, DEFAULT_ELEMENT_COLUMN_NAME, true, table, root);
}
else if ( "many-to-many".equals(name) ) {
--- 145,149 ----
}
else if ( "element".equals(name) ) {
! element = new Value(subnode, DEFAULT_ELEMENT_COLUMN_NAME, true, table, root);
}
else if ( "many-to-many".equals(name) ) {
Index: Component.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Component.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Component.java 1 Jan 2003 13:56:15 -0000 1.1.1.1
--- Component.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 94,98 ****
Collection collection = collectType.create( list.item(i), path, owner, root );
root.addCollection(collection);
! value = new Value(subnode, path, isNullable, table, root);
}
else if ( "many-to-one".equals(name) || "key-many-to-one".equals(name) ) {
--- 94,99 ----
Collection collection = collectType.create( list.item(i), path, owner, root );
root.addCollection(collection);
! value = new Value(subnode, isNullable, table, root);
! value.setType( collection.getType() );
}
else if ( "many-to-one".equals(name) || "key-many-to-one".equals(name) ) {
***************
*** 103,110 ****
}
else if ( "property".equals(name) || "key-property".equals(name) ) {
! value = new Value(subnode, Root.ROOT_ROLE_NAME, propertyName, isNullable, table, root);
}
else if ( "collection".equals(name) ) {
! value = new Value(subnode, Root.ROOT_ROLE_NAME, propertyName, isNullable, table, root);
}
else if ( "component".equals(name) || "nested-composite-element".equals(name) ) {
--- 104,111 ----
}
else if ( "property".equals(name) || "key-property".equals(name) ) {
! value = new Value(subnode, propertyName, isNullable, table, root);
}
else if ( "collection".equals(name) ) {
! value = new Value(subnode, propertyName, isNullable, table, root);
}
else if ( "component".equals(name) || "nested-composite-element".equals(name) ) {
Index: IntegerValue.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/IntegerValue.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** IntegerValue.java 1 Jan 2003 13:56:16 -0000 1.1.1.1
--- IntegerValue.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 14,18 ****
public IntegerValue(Node node, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, null, defaultColumnName, isNullable, table, root);
Column col = ( (Column) getColumnIterator().next() );
col.setType( getType() );
--- 14,18 ----
public IntegerValue(Node node, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, defaultColumnName, isNullable, table, root);
Column col = ( (Column) getColumnIterator().next() );
col.setType( getType() );
Index: ManyToOne.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/ManyToOne.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ManyToOne.java 1 Jan 2003 13:56:16 -0000 1.1.1.1
--- ManyToOne.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 19,23 ****
}
! protected Type typeFromXML(Node node, String path, Root root) throws MappingException {
NamedNodeMap atts = node.getAttributes();
--- 19,23 ----
}
! protected Type typeFromXML(Node node) throws MappingException {
NamedNodeMap atts = node.getAttributes();
Index: Map.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Map.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Map.java 1 Jan 2003 15:12:52 -0000 1.2
--- Map.java 2 Jan 2003 11:01:49 -0000 1.3
***************
*** 50,54 ****
if ( "index".equals(name) ) {
! setIndex( new Value(subnode, null, DEFAULT_INDEX_COLUMN_NAME, isOneToMany(), getTable(), root) );
if ( getIndex().getType()==null ) throw new MappingException("map index element must specify a type");
}
--- 50,54 ----
if ( "index".equals(name) ) {
! setIndex( new Value(subnode, DEFAULT_INDEX_COLUMN_NAME, isOneToMany(), getTable(), root) );
if ( getIndex().getType()==null ) throw new MappingException("map index element must specify a type");
}
Index: OneToOne.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/OneToOne.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** OneToOne.java 1 Jan 2003 13:56:18 -0000 1.1.1.1
--- OneToOne.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 24,32 ****
// A one-to-one association
public OneToOne(Node node, Value identifier, String path, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, path, isNullable, table, root);
this.identifier = identifier;
}
! protected Type typeFromXML(Node node, String path, Root root) throws MappingException {
NamedNodeMap atts = node.getAttributes();
--- 24,32 ----
// A one-to-one association
public OneToOne(Node node, Value identifier, String path, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, isNullable, table, root);
this.identifier = identifier;
}
! protected Type typeFromXML(Node node) throws MappingException {
NamedNodeMap atts = node.getAttributes();
Index: PersistentClass.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/PersistentClass.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PersistentClass.java 1 Jan 2003 13:56:19 -0000 1.1.1.1
--- PersistentClass.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 71,75 ****
Collection collection = collectType.create(subnode, path, this, root);
root.addCollection(collection);
! value = new Value(subnode, path, true, table, root);
}
else if ( "many-to-one".equals(name) ) {
--- 71,76 ----
Collection collection = collectType.create(subnode, path, this, root);
root.addCollection(collection);
! value = new Value(subnode, true, table, root);
! value.setType( collection.getType() );
}
else if ( "many-to-one".equals(name) ) {
***************
*** 80,87 ****
}
else if ( "property".equals(name) ) {
! value = new Value(subnode, Root.ROOT_ROLE_NAME, propertyName, true, table, root);
! }
! else if ( "collection".equals(name) ) {
! value = new Value(subnode, Root.ROOT_ROLE_NAME, propertyName, true, table, root);
}
else if ( "component".equals(name) ) {
--- 81,85 ----
}
else if ( "property".equals(name) ) {
! value = new Value(subnode, propertyName, true, table, root);
}
else if ( "component".equals(name) ) {
Index: Root.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Root.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Root.java 1 Jan 2003 13:56:21 -0000 1.1.1.1
--- Root.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 141,149 ****
}
! public Type getCollectionType(String role) throws MappingException {
Collection coll = (Collection) collections.get(role);
if (coll==null) throw new MappingException("undeclared collection role: " + role );
return coll.getType();
! }
public void addPersistentClass(PersistentClass persistentClass) throws MappingException {
--- 141,149 ----
}
! /*public Type getCollectionType(String role) throws MappingException {
Collection coll = (Collection) collections.get(role);
if (coll==null) throw new MappingException("undeclared collection role: " + role );
return coll.getType();
! }*/
public void addPersistentClass(PersistentClass persistentClass) throws MappingException {
Index: RootClass.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/RootClass.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** RootClass.java 1 Jan 2003 13:56:23 -0000 1.1.1.1
--- RootClass.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 139,148 ****
if ( "id".equals(name) ) {
if (propertyName==null) {
! identifier = new Value(subnode, null, DEFAULT_IDENTIFIER_COLUMN_NAME, false, table, root);
if (identifier.getType()==null) throw new MappingException( "must specify an identifier type: " + getPersistentClass().getName() );
identifierProperty = null;
}
else {
! identifier = new Value(subnode, null, propertyName, false, table, root);
identifier.setTypeByReflection( getPersistentClass(), propertyName );
identifierProperty = new Property(subnode, identifier, root);
--- 139,148 ----
if ( "id".equals(name) ) {
if (propertyName==null) {
! identifier = new Value(subnode, DEFAULT_IDENTIFIER_COLUMN_NAME, false, table, root);
if (identifier.getType()==null) throw new MappingException( "must specify an identifier type: " + getPersistentClass().getName() );
identifierProperty = null;
}
else {
! identifier = new Value(subnode, propertyName, false, table, root);
identifier.setTypeByReflection( getPersistentClass(), propertyName );
identifierProperty = new Property(subnode, identifier, root);
***************
*** 166,170 ****
else if ( "version".equals(name) || "timestamp".equals(name) ) {
//VERSION
! Value val = new Value(subnode, null, propertyName, false, table, root);
if ( val.getType()==null ) val.setType( "version".equals(name) ? Hibernate.INTEGER : Hibernate.TIMESTAMP );
version = new Property(subnode, val, root);
--- 166,170 ----
else if ( "version".equals(name) || "timestamp".equals(name) ) {
//VERSION
! Value val = new Value(subnode, propertyName, false, table, root);
if ( val.getType()==null ) val.setType( "version".equals(name) ? Hibernate.INTEGER : Hibernate.TIMESTAMP );
version = new Property(subnode, val, root);
***************
*** 173,177 ****
else if ( "discriminator".equals(name) ) {
//DISCRIMINATOR
! discriminator = new Value(subnode, null, DEFAULT_DISCRIMINATOR_COLUMN_NAME, false, table, root);
if ( discriminator.getType()==null ) {
discriminator.setType(Hibernate.STRING);
--- 173,177 ----
else if ( "discriminator".equals(name) ) {
//DISCRIMINATOR
! discriminator = new Value(subnode, DEFAULT_DISCRIMINATOR_COLUMN_NAME, false, table, root);
if ( discriminator.getType()==null ) {
discriminator.setType(Hibernate.STRING);
Index: Value.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Value.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Value.java 1 Jan 2003 13:56:27 -0000 1.1.1.1
--- Value.java 2 Jan 2003 11:01:49 -0000 1.2
***************
*** 62,66 ****
//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;
--- 62,66 ----
//Does _not_ automatically make a column if none is specifed by XML
! public Value(Node node, boolean isNullable, Table table, Root root) throws MappingException {
this.table = table;
***************
*** 68,72 ****
NamedNodeMap atts = node.getAttributes();
//TYPE
! type = typeFromXML(node, path, root);
//COLUMN(S)
Node columnName = atts.getNamedItem("column");
--- 68,72 ----
NamedNodeMap atts = node.getAttributes();
//TYPE
! type = typeFromXML(node);
//COLUMN(S)
Node columnName = atts.getNamedItem("column");
***************
*** 115,120 ****
//automatically makes a column with the default name if none is specifed by XML
! public Value(Node node, String path, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! this(node, path, isNullable, table, root);
if ( getColumnSpan()==0 ) {
Column col = new Column(node, isNullable, type, 0);
--- 115,120 ----
//automatically makes a column with the default name if none is specifed by XML
! public Value(Node node, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! this(node, isNullable, table, root);
if ( getColumnSpan()==0 ) {
Column col = new Column(node, isNullable, type, 0);
***************
*** 141,152 ****
}
! protected Type typeFromXML(Node node, String path, Root root) throws MappingException {
! return getTypeFromXML(node, path, root);
}
! static Type getTypeFromXML(Node node, String path, Root root) throws MappingException {
Type type;
NamedNodeMap atts = node.getAttributes();
! Node roleNode = atts.getNamedItem("role");
if (roleNode!=null) {
//System.out.println( path + Root.ROLE_SEPERATOR + roleNode.getNodeValue() );
--- 141,152 ----
}
! protected Type typeFromXML(Node node) throws MappingException {
! return getTypeFromXML(node);
}
! static Type getTypeFromXML(Node node) throws MappingException {
Type type;
NamedNodeMap atts = node.getAttributes();
! /*Node roleNode = atts.getNamedItem("role");
if (roleNode!=null) {
//System.out.println( path + Root.ROLE_SEPERATOR + roleNode.getNodeValue() );
***************
*** 155,159 ****
);
}
! else {
Node typeNode = atts.getNamedItem("type");
if (typeNode==null) {
--- 155,159 ----
);
}
! else {*/
Node typeNode = atts.getNamedItem("type");
if (typeNode==null) {
***************
*** 164,168 ****
if (type==null) throw new MappingException( "Could not interpret type: " + typeNode.getNodeValue() );
}
! }
return type;
}
--- 164,168 ----
if (type==null) throw new MappingException( "Could not interpret type: " + typeNode.getNodeValue() );
}
! //}
return type;
}
|