You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(22) |
Nov
(308) |
Dec
(131) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(369) |
Feb
(171) |
Mar
(236) |
Apr
(187) |
May
(218) |
Jun
(217) |
Jul
(127) |
Aug
(448) |
Sep
(270) |
Oct
(231) |
Nov
(422) |
Dec
(255) |
| 2004 |
Jan
(111) |
Feb
(73) |
Mar
(338) |
Apr
(351) |
May
(349) |
Jun
(495) |
Jul
(394) |
Aug
(1048) |
Sep
(499) |
Oct
(142) |
Nov
(269) |
Dec
(638) |
| 2005 |
Jan
(825) |
Feb
(1272) |
Mar
(593) |
Apr
(690) |
May
(950) |
Jun
(958) |
Jul
(767) |
Aug
(839) |
Sep
(525) |
Oct
(449) |
Nov
(585) |
Dec
(455) |
| 2006 |
Jan
(603) |
Feb
(656) |
Mar
(195) |
Apr
(114) |
May
(136) |
Jun
(100) |
Jul
(128) |
Aug
(68) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(8) |
| 2007 |
Jan
(4) |
Feb
(3) |
Mar
(8) |
Apr
(16) |
May
(5) |
Jun
(4) |
Jul
(6) |
Aug
(23) |
Sep
(15) |
Oct
(5) |
Nov
(7) |
Dec
(5) |
| 2008 |
Jan
(5) |
Feb
(1) |
Mar
(1) |
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <one...@us...> - 2003-01-27 12:51:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util
In directory sc8-pr-cvs1:/tmp/cvs-serv7052/sf/hibernate/util
Added Files:
Stringable.java
Log Message:
added stringability
fixed some naming conventions
--- NEW FILE: Stringable.java ---
package net.sf.hibernate.util;
import org.apache.commons.lang.builder.ToStringBuilder;
public class Stringable {
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping
In directory sc8-pr-cvs1:/tmp/cvs-serv7052/sf/hibernate/mapping
Modified Files:
Collection.java Column.java Constraint.java Index.java
PersistentClass.java Property.java Table.java Value.java
Log Message:
added stringability
fixed some naming conventions
Index: Collection.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Collection.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Collection.java 27 Jan 2003 12:12:41 -0000 1.11
--- Collection.java 27 Jan 2003 12:51:50 -0000 1.12
***************
*** 7,12 ****
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.type.PersistentCollectionType;
! public abstract class Collection {
public static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";
--- 7,13 ----
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.type.PersistentCollectionType;
+ import net.sf.hibernate.util.Stringable;
! public abstract class Collection extends Stringable {
public static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";
Index: Column.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Column.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Column.java 27 Jan 2003 07:12:03 -0000 1.5
--- Column.java 27 Jan 2003 12:51:50 -0000 1.6
***************
*** 7,12 ****
import net.sf.hibernate.engine.Mapping;
import net.sf.hibernate.type.Type;
! public class Column {
private static final int DEFAULT_PROPERTY_LENGTH = 255;
--- 7,13 ----
import net.sf.hibernate.engine.Mapping;
import net.sf.hibernate.type.Type;
+ import net.sf.hibernate.util.Stringable;
! public class Column extends Stringable {
private static final int DEFAULT_PROPERTY_LENGTH = 255;
Index: Constraint.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Constraint.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Constraint.java 5 Jan 2003 02:11:22 -0000 1.3
--- Constraint.java 27 Jan 2003 12:51:50 -0000 1.4
***************
*** 2,10 ****
package net.sf.hibernate.mapping;
! import java.util.*;
import net.sf.hibernate.dialect.Dialect;
import net.sf.hibernate.engine.Mapping;
! public abstract class Constraint implements RelationalModel {
private String name;
private final ArrayList columns = new ArrayList();
--- 2,14 ----
package net.sf.hibernate.mapping;
! import java.util.ArrayList;
! import java.util.Iterator;
!
import net.sf.hibernate.dialect.Dialect;
import net.sf.hibernate.engine.Mapping;
+ import net.sf.hibernate.util.Stringable;
! public abstract class Constraint extends Stringable implements RelationalModel {
!
private String name;
private final ArrayList columns = new ArrayList();
Index: Index.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Index.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Index.java 27 Jan 2003 07:12:03 -0000 1.5
--- Index.java 27 Jan 2003 12:51:50 -0000 1.6
***************
*** 8,14 ****
import net.sf.hibernate.engine.Mapping;
import net.sf.hibernate.util.StringHelper;
import net.sf.hibernate.dialect.Dialect;
! public class Index implements RelationalModel {
private Table table;
--- 8,15 ----
import net.sf.hibernate.engine.Mapping;
import net.sf.hibernate.util.StringHelper;
+ import net.sf.hibernate.util.Stringable;
import net.sf.hibernate.dialect.Dialect;
! public class Index extends Stringable implements RelationalModel {
private Table table;
Index: PersistentClass.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/PersistentClass.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PersistentClass.java 27 Jan 2003 12:12:41 -0000 1.9
--- PersistentClass.java 27 Jan 2003 12:51:50 -0000 1.10
***************
*** 8,13 ****
import net.sf.hibernate.util.JoinedIterator;
import net.sf.hibernate.util.StringHelper;
! public abstract class PersistentClass {
private Class persistentClass;
--- 8,14 ----
import net.sf.hibernate.util.JoinedIterator;
import net.sf.hibernate.util.StringHelper;
+ import net.sf.hibernate.util.Stringable;
! public abstract class PersistentClass extends Stringable {
private Class persistentClass;
Index: Property.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Property.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Property.java 27 Jan 2003 07:12:03 -0000 1.6
--- Property.java 27 Jan 2003 12:51:50 -0000 1.7
***************
*** 8,16 ****
import net.sf.hibernate.type.AbstractComponentType;
import net.sf.hibernate.type.Type;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
! public class Property {
private String name;
--- 8,17 ----
import net.sf.hibernate.type.AbstractComponentType;
import net.sf.hibernate.type.Type;
+ import net.sf.hibernate.util.Stringable;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
! public class Property extends Stringable {
private String name;
Index: Table.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Table.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Table.java 20 Jan 2003 12:48:13 -0000 1.5
--- Table.java 27 Jan 2003 12:51:50 -0000 1.6
***************
*** 15,22 ****
import net.sf.hibernate.tool.hbm2ddl.JdbcTableInfo;
import net.sf.hibernate.util.StringHelper;
import org.apache.commons.collections.SequencedHashMap;
! public class Table implements RelationalModel {
private String name;
private String schema;
--- 15,24 ----
import net.sf.hibernate.tool.hbm2ddl.JdbcTableInfo;
import net.sf.hibernate.util.StringHelper;
+ import net.sf.hibernate.util.Stringable;
import org.apache.commons.collections.SequencedHashMap;
! public class Table extends Stringable implements RelationalModel {
!
private String name;
private String schema;
***************
*** 62,75 ****
return columns.size();
}
! public Iterator columnIterator() {
return columns.values().iterator();
}
! public Iterator indexIterator() {
return indexes.values().iterator();
}
! public Iterator foreignKeyIterator() {
return foreignKeys.values().iterator();
}
! public Iterator uniqueKeyIterator() {
return uniqueKeys.values().iterator();
}
--- 64,77 ----
return columns.size();
}
! public Iterator getColumnIterator() {
return columns.values().iterator();
}
! public Iterator getIndexIterator() {
return indexes.values().iterator();
}
! public Iterator getForeignKeyIterator() {
return foreignKeys.values().iterator();
}
! public Iterator getUniqueKeyIterator() {
return uniqueKeys.values().iterator();
}
***************
*** 77,81 ****
public String sqlAlterString(Dialect dialect,Mapping p,JdbcTableInfo tableInfo) throws HibernateException {
! Iterator iter=columnIterator();
StringBuffer buf=new StringBuffer(50);
while (iter.hasNext()) {
--- 79,83 ----
public String sqlAlterString(Dialect dialect,Mapping p,JdbcTableInfo tableInfo) throws HibernateException {
! Iterator iter=getColumnIterator();
StringBuffer buf=new StringBuffer(50);
while (iter.hasNext()) {
***************
*** 116,120 ****
}
! Iterator iter = columnIterator();
while ( iter.hasNext() ) {
Column col = (Column) iter.next();
--- 118,122 ----
}
! Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
Column col = (Column) iter.next();
***************
*** 153,157 ****
}
if ( dialect.supportsUnique() ) {
! Iterator ukiter = uniqueKeyIterator();
while ( ukiter.hasNext() ) {
UniqueKey uk = (UniqueKey) ukiter.next();
--- 155,159 ----
}
if ( dialect.supportsUnique() ) {
! Iterator ukiter = getUniqueKeyIterator();
while ( ukiter.hasNext() ) {
UniqueKey uk = (UniqueKey) ukiter.next();
Index: Value.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Value.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Value.java 27 Jan 2003 12:12:41 -0000 1.8
--- Value.java 27 Jan 2003 12:51:50 -0000 1.9
***************
*** 14,17 ****
--- 14,18 ----
import net.sf.hibernate.type.Type;
import net.sf.hibernate.util.ReflectHelper;
+ import net.sf.hibernate.util.Stringable;
/**
***************
*** 21,25 ****
* to instances of this class.
*/
! public class Value {
//TODO: split this class into two - one that handles collections, and a second that handles basic types
//actually make "Value" be an interface
--- 22,26 ----
* to instances of this class.
*/
! public class Value extends Stringable {
//TODO: split this class into two - one that handles collections, and a second that handles basic types
//actually make "Value" be an interface
|
|
From: <one...@us...> - 2003-01-27 12:51:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv7052/sf/hibernate/cfg
Modified Files:
Configuration.java
Log Message:
added stringability
fixed some naming conventions
Index: Configuration.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Configuration.java 27 Jan 2003 12:12:40 -0000 1.8
--- Configuration.java 27 Jan 2003 12:51:49 -0000 1.9
***************
*** 283,287 ****
while ( iter.hasNext() ) {
Table table = (Table)iter.next();
! Iterator subIter = table.foreignKeyIterator();
while ( subIter.hasNext() ) {
ForeignKey fk = (ForeignKey)subIter.next();
--- 283,287 ----
while ( iter.hasNext() ) {
Table table = (Table)iter.next();
! Iterator subIter = table.getForeignKeyIterator();
while ( subIter.hasNext() ) {
ForeignKey fk = (ForeignKey)subIter.next();
***************
*** 327,331 ****
if ( dialect.hasAlterTable() ) {
! subIter = table.foreignKeyIterator();
while ( subIter.hasNext() ) {
ForeignKey fk = (ForeignKey) subIter.next();
--- 327,331 ----
if ( dialect.hasAlterTable() ) {
! subIter = table.getForeignKeyIterator();
while ( subIter.hasNext() ) {
ForeignKey fk = (ForeignKey) subIter.next();
***************
*** 334,338 ****
}
! subIter = table.indexIterator();
while ( subIter.hasNext() ) {
Index index = (Index) subIter.next();
--- 334,338 ----
}
! subIter = table.getIndexIterator();
while ( subIter.hasNext() ) {
Index index = (Index) subIter.next();
***************
*** 379,383 ****
if ( dialect.hasAlterTable() ) {
! subIter = table.foreignKeyIterator();
while (subIter.hasNext()) {
ForeignKey fk = (ForeignKey) subIter.next();
--- 379,383 ----
if ( dialect.hasAlterTable() ) {
! subIter = table.getForeignKeyIterator();
while (subIter.hasNext()) {
ForeignKey fk = (ForeignKey) subIter.next();
***************
*** 387,391 ****
}
! subIter = table.indexIterator();
while ( subIter.hasNext() ) {
Index index = (Index)subIter.next();
--- 387,391 ----
}
! subIter = table.getIndexIterator();
while ( subIter.hasNext() ) {
Index index = (Index)subIter.next();
***************
*** 423,427 ****
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
! Iterator subIter = table.foreignKeyIterator();
while ( subIter.hasNext() ) {
--- 423,427 ----
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
! Iterator subIter = table.getForeignKeyIterator();
while ( subIter.hasNext() ) {
|
|
From: <one...@us...> - 2003-01-27 12:39:37
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv2119/sf/hibernate/cfg
Modified Files:
Binder.java Mappings.java
Log Message:
minor cleanups
Index: Binder.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Binder.java 27 Jan 2003 12:12:40 -0000 1.2
--- Binder.java 27 Jan 2003 12:39:34 -0000 1.3
***************
*** 194,233 ****
String propertyName = Property.getPropertyName(subnode);
! if ( "id".equals(name) ) {
if (propertyName==null) {
! model.setIdentifier( new Value(table) );
! bindValue(subnode, model.getIdentifier(), false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME);
! if (model.getIdentifier().getType()==null) throw new MappingException( "must specify an identifier type: " + model.getPersistentClass().getName() );
model.setIdentifierProperty(null);
}
else {
! model.setIdentifier( new Value(table) );
! bindValue(subnode, model.getIdentifier(), false, propertyName);
! model.getIdentifier().setTypeByReflection( model.getPersistentClass(), propertyName );
Property prop = new Property();
! bindProperty(subnode, prop, model.getIdentifier(), mappings);
model.setIdentifierProperty(prop);
}
! if ( model.getIdentifier().getType().getReturnedClass().isArray() ) throw new MappingException(
"illegal use of an array as an identifier (arrays don't reimplement equals)"
);
! makeIdentifier( subnode, model.getIdentifier() );
}
! else if ( "composite-id".equals(name) ) {
if (propertyName==null) {
! model.setIdentifier( new Component(model) );
! bindComponent(subnode, (Component) model.getIdentifier(), null, null, false, mappings);
! model.setEmbeddedIdentifier( ( (Component) model.getIdentifier() ).isEmbedded() );
model.setIdentifierProperty(null);
}
else {
Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType();
! model.setIdentifier( new Component(model) );
! bindComponent(subnode, (Component) model.getIdentifier(), reflectedClass, null, false, mappings);
Property prop = new Property();
! bindProperty(subnode, prop, model.getIdentifier(), mappings);
model.setIdentifierProperty(prop);
}
! makeIdentifier( subnode, model.getIdentifier() );
}
else if ( "version".equals(name) || "timestamp".equals(name) ) {
--- 194,233 ----
String propertyName = Property.getPropertyName(subnode);
! if ( "id".equals(name) ) {
! Value id = new Value(table);
! model.setIdentifier(id);
if (propertyName==null) {
! bindValue(subnode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME);
! if (id.getType()==null) throw new MappingException( "must specify an identifier type: " + model.getPersistentClass().getName() );
model.setIdentifierProperty(null);
}
else {
! bindValue(subnode, id, false, propertyName);
! id.setTypeByReflection( model.getPersistentClass(), propertyName );
Property prop = new Property();
! bindProperty(subnode, prop, id, mappings);
model.setIdentifierProperty(prop);
}
! if ( id.getType().getReturnedClass().isArray() ) throw new MappingException(
"illegal use of an array as an identifier (arrays don't reimplement equals)"
);
! makeIdentifier(subnode, id);
}
! else if ( "composite-id".equals(name) ) {
! Component id = new Component(model);
! model.setIdentifier(id);
if (propertyName==null) {
! bindComponent(subnode, id, null, null, false, mappings);
! model.setEmbeddedIdentifier( id.isEmbedded() );
model.setIdentifierProperty(null);
}
else {
Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType();
! bindComponent(subnode, id, reflectedClass, null, false, mappings);
Property prop = new Property();
! bindProperty(subnode, prop, id, mappings);
model.setIdentifierProperty(prop);
}
! makeIdentifier(subnode, id);
}
else if ( "version".equals(name) || "timestamp".equals(name) ) {
***************
*** 242,251 ****
}
else if ( "discriminator".equals(name) ) {
! //DISCRIMINATOR
! model.setDiscriminator( new Value(table) );
! bindValue(subnode, model.getDiscriminator(), false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME);
! if ( model.getDiscriminator().getType()==null ) {
! model.getDiscriminator().setType(Hibernate.STRING);
! ( (Column) model.getDiscriminator().getColumnIterator().next() ).setType(Hibernate.STRING);
}
model.setPolymorphic(true);
--- 242,252 ----
}
else if ( "discriminator".equals(name) ) {
! //DISCRIMINATOR
! Value discrim = new Value(table);
! model.setDiscriminator(discrim);
! bindValue(subnode, discrim, false, RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME);
! if ( discrim.getType()==null ) {
! discrim.setType(Hibernate.STRING);
! ( (Column) discrim.getColumnIterator().next() ).setType(Hibernate.STRING);
}
model.setPolymorphic(true);
Index: Mappings.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Mappings.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Mappings.java 27 Jan 2003 12:12:40 -0000 1.1
--- Mappings.java 27 Jan 2003 12:39:34 -0000 1.2
***************
*** 23,27 ****
* A collection of mappings from classes and collections to
* relational database tables. (Represents a single
! * <tt><hibernate-mapping><tt> element.)
*/
public class Mappings {
--- 23,27 ----
* A collection of mappings from classes and collections to
* relational database tables. (Represents a single
! * <tt><hibernate-mapping></tt> element.)
*/
public class Mappings {
|
|
From: <one...@us...> - 2003-01-27 12:12:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping
In directory sc8-pr-cvs1:/tmp/cvs-serv24603/sf/hibernate/mapping
Modified Files:
Array.java Bag.java Collection.java IndexedCollection.java
List.java Map.java PersistentClass.java PrimitiveArray.java
Set.java Subclass.java Value.java
Removed Files:
Root.java
Log Message:
further clean-ups of mapping package
Index: Array.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Array.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Array.java 27 Jan 2003 07:12:03 -0000 1.6
--- Array.java 27 Jan 2003 12:12:40 -0000 1.7
***************
*** 5,8 ****
--- 5,12 ----
import net.sf.hibernate.type.TypeFactory;
+ /**
+ * An array has a primary key consisting of
+ * the key columns + index column.
+ */
public class Array extends List {
Index: Bag.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Bag.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Bag.java 27 Jan 2003 07:12:03 -0000 1.4
--- Bag.java 27 Jan 2003 12:12:41 -0000 1.5
***************
*** 5,8 ****
--- 5,11 ----
import net.sf.hibernate.type.TypeFactory;
+ /**
+ * A bag permits duplicates, so it has no primary key
+ */
public class Bag extends Collection {
***************
*** 23,30 ****
}
- public void createPrimaryKey() {
- //do nothing .. bags have no PK
- }
-
}
--- 26,29 ----
Index: Collection.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Collection.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Collection.java 27 Jan 2003 07:12:03 -0000 1.10
--- Collection.java 27 Jan 2003 12:12:41 -0000 1.11
***************
*** 5,10 ****
import java.util.Iterator;
- import org.w3c.dom.Node;
-
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.type.PersistentCollectionType;
--- 5,8 ----
***************
*** 26,35 ****
private String orderBy;
private PersistentClass owner;
-
- //TODO: remove these ugly instance vars
- public Node node;
- public Root root;
- public boolean doneSecondPass;
-
private boolean sorted;
private Comparator comparator;
--- 24,27 ----
***************
*** 105,109 ****
return index;
}
! public abstract void createPrimaryKey();
public CacheConcurrencyStrategy getCache() {
--- 97,101 ----
return index;
}
! // public abstract void createPrimaryKey();
public CacheConcurrencyStrategy getCache() {
Index: IndexedCollection.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/IndexedCollection.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** IndexedCollection.java 27 Jan 2003 07:12:03 -0000 1.5
--- IndexedCollection.java 27 Jan 2003 12:12:41 -0000 1.6
***************
*** 4,7 ****
--- 4,11 ----
import java.util.Iterator;
+ /**
+ * Indexed collections include Lists, Maps, arrays and
+ * primitive arrays.
+ */
public abstract class IndexedCollection extends Collection {
Index: List.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/List.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** List.java 27 Jan 2003 07:12:03 -0000 1.5
--- List.java 27 Jan 2003 12:12:41 -0000 1.6
***************
*** 5,8 ****
--- 5,12 ----
import net.sf.hibernate.type.TypeFactory;
+ /**
+ * A list has a primary key consisting of
+ * the key columns + index column.
+ */
public class List extends IndexedCollection {
Index: Map.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Map.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Map.java 27 Jan 2003 07:12:03 -0000 1.8
--- Map.java 27 Jan 2003 12:12:41 -0000 1.9
***************
*** 5,8 ****
--- 5,12 ----
import net.sf.hibernate.type.TypeFactory;
+ /**
+ * A map has a primary key consisting of
+ * the key columns + index columns.
+ */
public class Map extends IndexedCollection {
Index: PersistentClass.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/PersistentClass.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** PersistentClass.java 27 Jan 2003 07:12:03 -0000 1.8
--- PersistentClass.java 27 Jan 2003 12:12:41 -0000 1.9
***************
*** 7,10 ****
--- 7,11 ----
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.util.JoinedIterator;
+ import net.sf.hibernate.util.StringHelper;
public abstract class PersistentClass {
***************
*** 152,155 ****
--- 153,169 ----
public void setProxyInterface(Class proxyInterface) {
this.proxyInterface = proxyInterface;
+ }
+
+ public void createPrimaryKey() {
+ //Primary key constraint
+ PrimaryKey pk = new PrimaryKey();
+ pk.setTable(table);
+ pk.setName( StringHelper.suffix( table.getName(), "PK" ) );
+ table.setPrimaryKey(pk);
+
+ Iterator iter = getKey().getColumnIterator();
+ while ( iter.hasNext() ) {
+ pk.addColumn( (Column) iter.next() );
+ }
}
Index: PrimitiveArray.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/PrimitiveArray.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PrimitiveArray.java 27 Jan 2003 07:12:03 -0000 1.5
--- PrimitiveArray.java 27 Jan 2003 12:12:41 -0000 1.6
***************
*** 2,5 ****
--- 2,9 ----
package net.sf.hibernate.mapping;
+ /**
+ * A primitive array has a primary key consisting
+ * of the key columns + index column.
+ */
public class PrimitiveArray extends Array {
Index: Set.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Set.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Set.java 27 Jan 2003 07:12:03 -0000 1.4
--- Set.java 27 Jan 2003 12:12:41 -0000 1.5
***************
*** 7,11 ****
import net.sf.hibernate.type.TypeFactory;
!
public class Set extends Collection {
--- 7,15 ----
import net.sf.hibernate.type.TypeFactory;
! /**
! * A set with no nullable element columns will have a primary
! * key consisting of all table columns (ie. key columns +
! * element columns).
! */
public class Set extends Collection {
***************
*** 23,31 ****
public PersistentCollectionType getType() {
! return isSorted() ? TypeFactory.sortedSet( getRole(), getComparator() ) : TypeFactory.set( getRole() );
}
public Class wrapperClass() {
! return isSorted() ? net.sf.hibernate.collection.SortedSet.class : net.sf.hibernate.collection.Set.class;
}
--- 27,39 ----
public PersistentCollectionType getType() {
! return isSorted() ?
! TypeFactory.sortedSet( getRole(), getComparator() ) :
! TypeFactory.set( getRole() );
}
public Class wrapperClass() {
! return isSorted() ?
! net.sf.hibernate.collection.SortedSet.class :
! net.sf.hibernate.collection.Set.class;
}
Index: Subclass.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Subclass.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Subclass.java 27 Jan 2003 07:12:03 -0000 1.8
--- Subclass.java 27 Jan 2003 12:12:41 -0000 1.9
***************
*** 10,19 ****
public class Subclass extends PersistentClass {
public Subclass(PersistentClass superclass) {
this.superclass = superclass;
}
-
- private PersistentClass superclass;
- private Value key;
public CacheConcurrencyStrategy getCache() {
--- 10,19 ----
public class Subclass extends PersistentClass {
+ private PersistentClass superclass;
+ private Value key;
+
public Subclass(PersistentClass superclass) {
this.superclass = superclass;
}
public CacheConcurrencyStrategy getCache() {
Index: Value.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Value.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Value.java 27 Jan 2003 07:12:03 -0000 1.7
--- Value.java 27 Jan 2003 12:12:41 -0000 1.8
***************
*** 15,18 ****
--- 15,24 ----
import net.sf.hibernate.util.ReflectHelper;
+ /**
+ * A value represents a simple thing that maps down to
+ * a table column or columns. Higher level things like
+ * classes, properties and collections add semantics
+ * to instances of this class.
+ */
public class Value {
//TODO: split this class into two - one that handles collections, and a second that handles basic types
--- Root.java DELETED ---
|
|
From: <one...@us...> - 2003-01-27 12:12:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv24603/sf/hibernate/test Modified Files: Multi.hbm.xml Qux.hbm.xml Log Message: further clean-ups of mapping package Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Multi.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Multi.hbm.xml 25 Jan 2003 01:26:07 -0000 1.3 --- Multi.hbm.xml 27 Jan 2003 12:12:41 -0000 1.4 *************** *** 30,34 **** <bag name="bag" lazy="true" table="simple_simple"> <key column="simple1"/> ! <many-to-many column="simple2" class="net.sf.hibernate.test.Simple"/> </bag> <one-to-one name="mypo"/> --- 30,34 ---- <bag name="bag" lazy="true" table="simple_simple"> <key column="simple1"/> ! <many-to-many column="simple2" class="net.sf.hibernate.test.Simple" not-null="true"/> </bag> <one-to-one name="mypo"/> Index: Qux.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Qux.hbm.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Qux.hbm.xml 9 Jan 2003 12:24:51 -0000 1.2 --- Qux.hbm.xml 27 Jan 2003 12:12:41 -0000 1.3 *************** *** 19,25 **** <key column="qux_id"/> <many-to-many class="net.sf.hibernate.test.Fum"> ! <column name="fum_string" length="10"/> ! <column name="fum_short"/> ! <column name="fum_date"/> </many-to-many> </set> --- 19,25 ---- <key column="qux_id"/> <many-to-many class="net.sf.hibernate.test.Fum"> ! <column name="fum_string" length="10" not-null="true"/> ! <column name="fum_short" not-null="true"/> ! <column name="fum_date" not-null="true"/> </many-to-many> </set> |
|
From: <one...@us...> - 2003-01-27 12:12:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type
In directory sc8-pr-cvs1:/tmp/cvs-serv24603/sf/hibernate/type
Modified Files:
AbstractType.java
Log Message:
further clean-ups of mapping package
Index: AbstractType.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/AbstractType.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AbstractType.java 5 Jan 2003 02:11:24 -0000 1.3
--- AbstractType.java 27 Jan 2003 12:12:41 -0000 1.4
***************
*** 11,15 ****
/**
! * Root of the built in Type hierarchy.
*/
public abstract class AbstractType implements Type {
--- 11,15 ----
/**
! * Mapping of the built in Type hierarchy.
*/
public abstract class AbstractType implements Type {
|
|
From: <one...@us...> - 2003-01-27 12:12:43
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv24603/sf/hibernate/cfg
Modified Files:
Binder.java Configuration.java
Added Files:
Mappings.java
Log Message:
further clean-ups of mapping package
--- NEW FILE: Mappings.java ---
//$Id: Mappings.java,v 1.1 2003/01/27 12:12:40 oneovthafew Exp $
package net.sf.hibernate.cfg;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.cache.Cache;
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.cache.CacheException;
import net.sf.hibernate.cache.JCSCache;
import net.sf.hibernate.cache.ReadOnlyCache;
import net.sf.hibernate.cache.ReadWriteCache;
import net.sf.hibernate.mapping.Collection;
import net.sf.hibernate.mapping.PersistentClass;
import net.sf.hibernate.mapping.Table;
import net.sf.hibernate.util.StringHelper;
/**
* A collection of mappings from classes and collections to
* relational database tables. (Represents a single
* <tt><hibernate-mapping><tt> element.)
*/
public class Mappings {
public static final String ROOT_ROLE_NAME = StringHelper.EMPTY_STRING;
public static final char ROLE_SEPERATOR = '/';
private static final Log log = LogFactory.getLog(Mappings.class);
private final Map classes;
private final Map collections;
private final Map tables;
private final Map queries;
private final List secondPasses;
private String schemaName;
private String defaultCascade;
Mappings(Map classes, Map collections, Map tables, Map queries, List secondPasses) {
this.classes = classes;
this.collections = collections;
this.queries = queries;
this.tables = tables;
this.secondPasses = secondPasses;
}
public void addClass(PersistentClass persistentClass) throws MappingException {
Object old = classes.put( persistentClass.getPersistentClass(), persistentClass );
if ( old!=null ) throw new MappingException( "duplicate class mapping: " + persistentClass.getPersistentClass().getName() );
}
public void addCollection(Collection collection) throws MappingException {
Object old = collections.put( collection.getRole(), collection );
if ( old!=null ) throw new MappingException( "duplicate collection role: " + collection.getRole() );
}
public PersistentClass getClass(Class clazz) {
return (PersistentClass) classes.get(clazz);
}
public Collection getCollection(String role) {
return (Collection) collections.get(role);
}
public Table addTable(String schema, String name) {
String key = schema != null ? schema + "." + name : name;
Table table = (Table) tables.get(key);
if (table == null) {
table = new Table();
table.setName(name);
table.setSchema(schema);
tables.put(key, table);
}
return table;
}
public Table getTable(String schema, String name) {
String key = schema != null ? schema + "." + name : name;
return (Table) tables.get(key);
}
public String getSchemaName() {
return schemaName;
}
public String getDefaultCascade() {
return defaultCascade;
}
public CacheConcurrencyStrategy createJCSCache(String usage, String name, PersistentClass owner) throws MappingException {
final Cache jcs;
try {
jcs = new JCSCache();
}
catch (NoClassDefFoundError ncf) {
log.warn( "Could not instantiate cache - probably the JCS jar is missing", ncf );
// continue with no cache
return null;
}
try {
jcs.setClass(name);
}
catch (CacheException ce) {
throw new MappingException("Could not instantiate JCS",ce);
}
if ( usage.equals("read-only") ) {
if ( owner.isMutable() ) log.warn( "read-only cache configured for mutable: " + name );
return new ReadOnlyCache(jcs);
}
else if ( usage.equals("read-write") ) {
return new ReadWriteCache(jcs);
}
else {
throw new MappingException("jcs-cache usage attribute should be read-write or read-only");
}
}
/**
* Sets the schemaName.
* @param schemaName The schemaName to set
*/
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
/**
* Sets the defaultCascade.
* @param defaultCascade The defaultCascade to set
*/
public void setDefaultCascade(String defaultCascade) {
this.defaultCascade = defaultCascade;
}
public void addQuery(String name, String query) throws MappingException {
Object old = queries.put(name, query);
if (old!=null) throw new MappingException("duplicate query name: " + name);
}
public String getQuery(String name) {
return (String) queries.get(name);
}
void addSecondPass(Binder.SecondPass sp) {
secondPasses.add(sp);
}
}
Index: Binder.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Binder.java 27 Jan 2003 07:12:03 -0000 1.1
--- Binder.java 27 Jan 2003 12:12:40 -0000 1.2
***************
*** 26,33 ****
import net.sf.hibernate.mapping.OneToOne;
import net.sf.hibernate.mapping.PersistentClass;
- import net.sf.hibernate.mapping.PrimaryKey;
import net.sf.hibernate.mapping.PrimitiveArray;
import net.sf.hibernate.mapping.Property;
- import net.sf.hibernate.mapping.Root;
import net.sf.hibernate.mapping.RootClass;
import net.sf.hibernate.mapping.Set;
--- 26,31 ----
***************
*** 57,61 ****
import org.w3c.dom.NodeList;
! public class Binder {
private static final Log log = LogFactory.getLog(Collection.class);
--- 55,59 ----
import org.w3c.dom.NodeList;
! class Binder {
private static final Log log = LogFactory.getLog(Collection.class);
***************
*** 96,167 ****
}
! public static void bindSubclass(Node node, Subclass model, Root root) throws MappingException {
bindClass(node, model);
! NamedNodeMap atts = node.getAttributes();
!
! String mappingStyle = node.getNodeName();
! // TODO: split this class into 2 different subclasses
! // one for joined, one for "normal" (same table)
! if ( "subclass".equals(mappingStyle) ) {
! //ordinary subclasses
!
! if ( model.getPersister()==null ) {
! model.getRootClass().setPersister(EntityPersister.class);
! }
!
! model.setTable( model.getSuperclass().getTable() );
! }
! else {
!
! Node tableNameNode = atts.getNamedItem("table");
!
! if ( model.getPersister()==null ) {
! model.getRootClass().setPersister(NormalizedEntityPersister.class);
! }
!
! // joined subclasses
! String tableName = (tableNameNode==null) ?
! StringHelper.unqualify( model.getPersistentClass().getName() ) :
! tableNameNode.getNodeValue();
! Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? root.getSchemaName() : schemaNode.getNodeValue();
! Table mytable = root.addTable(schema, tableName);
! model.setTable(mytable);
!
! //Primary key constraint
! PrimaryKey pk = new PrimaryKey();
! pk.setTable(mytable);
! pk.setName( StringHelper.suffix( tableName, "PK" ) );
! mytable.setPrimaryKey(pk);
!
! NodeList subnodes = node.getChildNodes();
! for ( int i=0; i<subnodes.getLength(); i++ ) {
! if ( "key".equals( subnodes.item(i).getNodeName() ) ) {
! Value key = new Value(mytable);
! model.setKey(key);
! bindValue( subnodes.item(i), key, false, Root.ROOT_ROLE_NAME );
! }
! }
!
! model.getKey().setType( model.getIdentifier().getType() );
!
! Iterator iter = model.getKey().getColumnIterator();
! while ( iter.hasNext() ) {
! Column col = (Column) iter.next();
! pk.addColumn(col);
! }
!
! ForeignKey fk = mytable.createForeignKey( model.getKey().getConstraintColumns() );
! fk.setReferencedClass( model.getSuperclass().getPersistentClass() );
!
}
// properties
! propertiesFromXML(node, model, root);
}
! public static void bindRootClass(Node node, RootClass model, Root root) throws MappingException {
bindClass(node, model);
--- 94,152 ----
}
! public static void bindSubclass(Node node, Subclass model, Mappings mappings) throws MappingException {
bindClass(node, model);
! if ( model.getPersister()==null ) {
! model.getRootClass().setPersister(EntityPersister.class);
}
+ model.setTable( model.getSuperclass().getTable() );
+
// properties
! propertiesFromXML(node, model, mappings);
}
! public static void bindJoinedSubclass(Node node, Subclass model, Mappings mappings) throws MappingException {
!
! bindClass(node, model);
!
! NamedNodeMap atts = node.getAttributes();
!
! Node tableNameNode = atts.getNamedItem("table");
!
! if ( model.getPersister()==null ) {
! model.getRootClass().setPersister(NormalizedEntityPersister.class);
! }
!
! // joined subclasses
! String tableName = (tableNameNode==null) ?
! StringHelper.unqualify( model.getPersistentClass().getName() ) :
! tableNameNode.getNodeValue();
! Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? mappings.getSchemaName() : schemaNode.getNodeValue();
! Table mytable = mappings.addTable(schema, tableName);
! model.setTable(mytable);
!
! NodeList subnodes = node.getChildNodes();
! for ( int i=0; i<subnodes.getLength(); i++ ) {
! if ( "key".equals( subnodes.item(i).getNodeName() ) ) {
! Value key = new Value(mytable);
! model.setKey(key);
! bindValue( subnodes.item(i), key, false, Mappings.ROOT_ROLE_NAME );
! }
! }
!
! model.getKey().setType( model.getIdentifier().getType() );
! model.createPrimaryKey();
! ForeignKey fk = mytable.createForeignKey( model.getKey().getConstraintColumns() );
! fk.setReferencedClass( model.getSuperclass().getPersistentClass() );
!
!
! // properties
! propertiesFromXML(node, model, mappings);
! }
!
! public static void bindRootClass(Node node, RootClass model, Mappings mappings) throws MappingException {
bindClass(node, model);
***************
*** 176,181 ****
Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? root.getSchemaName() : schemaNode.getNodeValue();
! Table table = root.addTable(schema, tableName);
model.setTable(table);
--- 161,166 ----
Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? mappings.getSchemaName() : schemaNode.getNodeValue();
! Table table = mappings.addTable(schema, tableName);
model.setTable(table);
***************
*** 221,225 ****
model.getIdentifier().setTypeByReflection( model.getPersistentClass(), propertyName );
Property prop = new Property();
! bindProperty(subnode, prop, model.getIdentifier(), root);
model.setIdentifierProperty(prop);
}
--- 206,210 ----
model.getIdentifier().setTypeByReflection( model.getPersistentClass(), propertyName );
Property prop = new Property();
! bindProperty(subnode, prop, model.getIdentifier(), mappings);
model.setIdentifierProperty(prop);
}
***************
*** 232,236 ****
if (propertyName==null) {
model.setIdentifier( new Component(model) );
! bindComponent(subnode, (Component) model.getIdentifier(), null, null, false, root);
model.setEmbeddedIdentifier( ( (Component) model.getIdentifier() ).isEmbedded() );
model.setIdentifierProperty(null);
--- 217,221 ----
if (propertyName==null) {
model.setIdentifier( new Component(model) );
! bindComponent(subnode, (Component) model.getIdentifier(), null, null, false, mappings);
model.setEmbeddedIdentifier( ( (Component) model.getIdentifier() ).isEmbedded() );
model.setIdentifierProperty(null);
***************
*** 239,245 ****
Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType();
model.setIdentifier( new Component(model) );
! bindComponent(subnode, (Component) model.getIdentifier(), reflectedClass, null, false, root);
Property prop = new Property();
! bindProperty(subnode, prop, model.getIdentifier(), root);
model.setIdentifierProperty(prop);
}
--- 224,230 ----
Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType();
model.setIdentifier( new Component(model) );
! bindComponent(subnode, (Component) model.getIdentifier(), reflectedClass, null, false, mappings);
Property prop = new Property();
! bindProperty(subnode, prop, model.getIdentifier(), mappings);
model.setIdentifierProperty(prop);
}
***************
*** 252,256 ****
if ( val.getType()==null ) val.setType( "version".equals(name) ? Hibernate.INTEGER : Hibernate.TIMESTAMP );
Property prop = new Property();
! bindProperty(subnode, prop, val, root);
model.setVersion(prop);
model.addProperty(prop);
--- 237,241 ----
if ( val.getType()==null ) val.setType( "version".equals(name) ? Hibernate.INTEGER : Hibernate.TIMESTAMP );
Property prop = new Property();
! bindProperty(subnode, prop, val, mappings);
model.setVersion(prop);
model.addProperty(prop);
***************
*** 267,271 ****
}
else if ( "jcs-cache".equals(name) ) {
! model.setCache( root.createJCSCache(
subnode.getAttributes().getNamedItem("usage").getNodeValue(),
model.getPersistentClass().getName(),
--- 252,256 ----
}
else if ( "jcs-cache".equals(name) ) {
! model.setCache( mappings.createJCSCache(
subnode.getAttributes().getNamedItem("usage").getNodeValue(),
model.getPersistentClass().getName(),
***************
*** 274,290 ****
}
! }
//Primary key constraint
! PrimaryKey pk = new PrimaryKey();
! pk.setTable(table);
! pk.setName( StringHelper.suffix( table.getName(), "PK" ) );
! Iterator iter = model.getIdentifier().getColumnIterator();
! while ( iter.hasNext() ) {
! pk.addColumn( (Column) iter.next() );
! }
! //root.addPrimaryKey(pk); //No good for postgres
! table.setPrimaryKey(pk);
! propertiesFromXML(node, model, root);
}
--- 259,268 ----
}
! }
!
//Primary key constraint
! model.createPrimaryKey();
! propertiesFromXML(node, model, mappings);
}
***************
*** 354,358 ****
}
! public static void bindProperty(Node node, Property model, Value value, Root root) throws MappingException {
model.setName( Property.getPropertyName(node) );
model.setValue(value);
--- 332,336 ----
}
! public static void bindProperty(Node node, Property model, Value value, Mappings mappings) throws MappingException {
model.setName( Property.getPropertyName(node) );
model.setValue(value);
***************
*** 361,365 ****
Node cascadeNode = node.getAttributes().getNamedItem("cascade");
model.setCascade( (cascadeNode==null) ?
! root.getDefaultCascade() :
cascadeNode.getNodeValue()
);
--- 339,343 ----
Node cascadeNode = node.getAttributes().getNamedItem("cascade");
model.setCascade( (cascadeNode==null) ?
! mappings.getDefaultCascade() :
cascadeNode.getNodeValue()
);
***************
*** 370,377 ****
);
}
- public static void bindCollection(Node node, Collection model, String prefix, Root root) throws MappingException {
- model.node = node;
- model.root = root;
NamedNodeMap atts = node.getAttributes();
//ROLENAME
--- 348,357 ----
);
}
+
+ /**
+ * Called for all collections
+ */
+ public static void bindCollection(Node node, Collection model, String prefix, Mappings mappings) throws MappingException {
NamedNodeMap atts = node.getAttributes();
//ROLENAME
***************
*** 379,383 ****
if (roleAtt==null) roleAtt = atts.getNamedItem("role");
String barerole = roleAtt.getNodeValue();
! model.setRole( prefix + Root.ROLE_SEPERATOR + barerole );
Node inverseNode = atts.getNamedItem("inverse");
--- 359,363 ----
if (roleAtt==null) roleAtt = atts.getNamedItem("role");
String barerole = roleAtt.getNodeValue();
! model.setRole( prefix + Mappings.ROLE_SEPERATOR + barerole );
Node inverseNode = atts.getNamedItem("inverse");
***************
*** 418,423 ****
}
Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? root.getSchemaName() : schemaNode.getNodeValue();
! model.setTable( root.addTable(schema, tableName) );
}
//LAZINESS
--- 398,403 ----
}
Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? mappings.getSchemaName() : schemaNode.getNodeValue();
! model.setTable( mappings.addTable(schema, tableName) );
}
//LAZINESS
***************
*** 444,447 ****
--- 424,441 ----
}
}
+ }
+
+ //set up second pass
+ if (model instanceof List) {
+ mappings.addSecondPass( new ListSecondPass(node, mappings, (List) model) );
+ }
+ else if (model instanceof Set) {
+ mappings.addSecondPass( new SetSecondPass(node, mappings, (Set) model) );
+ }
+ else if (model instanceof Map) {
+ mappings.addSecondPass( new MapSecondPass(node, mappings, (Map) model) );
+ }
+ else {
+ mappings.addSecondPass( new CollectionSecondPass(node, mappings, model) );
}
}
***************
*** 522,529 ****
model.setSqlType( (typeNode==null) ? null : typeNode.getNodeValue() );
}
!
! public static void bindArray(Node node, Array model, String prefix, Root root) throws MappingException {
- bindCollection(node, model, prefix, root);
Node att = node.getAttributes().getNamedItem("element-class");
--- 516,527 ----
model.setSqlType( (typeNode==null) ? null : typeNode.getNodeValue() );
}
!
! /**
! * Called for arrays and primitive arrays
! */
! public static void bindArray(Node node, Array model, String prefix, Mappings mappings) throws MappingException {
!
! bindCollection(node, model, prefix, mappings);
Node att = node.getAttributes().getNamedItem("element-class");
***************
*** 566,570 ****
}
! public static void bindComponent(Node node, Component model, Class reflectedClass, String path, boolean isNullable, Root root) throws MappingException {
Node classNode = node.getAttributes().getNamedItem("class");
--- 564,568 ----
}
! public static void bindComponent(Node node, Component model, Class reflectedClass, String path, boolean isNullable, Mappings mappings) throws MappingException {
Node classNode = node.getAttributes().getNamedItem("class");
***************
*** 600,604 ****
//component path
! path += Root.ROLE_SEPERATOR + StringHelper.unqualify(className);
NodeList list = node.getChildNodes();
--- 598,602 ----
//component path
! path += Mappings.ROLE_SEPERATOR + StringHelper.unqualify(className);
NodeList list = node.getChildNodes();
***************
*** 612,617 ****
Value value = null;
if (collectType!=null) {
! Collection collection = collectType.create( list.item(i), path, model.getOwner(), root );
! root.addCollection(collection);
value = new Value( model.getTable() );
bindValue(subnode, value, isNullable);
--- 610,615 ----
Value value = null;
if (collectType!=null) {
! Collection collection = collectType.create( list.item(i), path, model.getOwner(), mappings );
! mappings.addCollection(collection);
value = new Value( model.getTable() );
bindValue(subnode, value, isNullable);
***************
*** 637,641 ****
new Component( model.getOwner() ) : // a class component
new Component( model.getTable() ); // a composite element
! bindComponent(subnode, (Component) value, subreflectedClass, path, isNullable, root);
}
else if ( "parent".equals(name) ) {
--- 635,639 ----
new Component( model.getOwner() ) : // a class component
new Component( model.getTable() ); // a composite element
! bindComponent(subnode, (Component) value, subreflectedClass, path, isNullable, mappings);
}
else if ( "parent".equals(name) ) {
***************
*** 647,651 ****
value.createForeignKey();
Property prop = new Property();
! bindProperty(subnode, prop, value, root);
model.addProperty(prop);
}
--- 645,649 ----
value.createForeignKey();
Property prop = new Property();
! bindProperty(subnode, prop, value, mappings);
model.addProperty(prop);
}
***************
*** 746,750 ****
}
! protected static void propertiesFromXML(Node node, PersistentClass model, Root root) throws MappingException {
NodeList list = node.getChildNodes();
--- 744,748 ----
}
! protected static void propertiesFromXML(Node node, PersistentClass model, Mappings mappings) throws MappingException {
NodeList list = node.getChildNodes();
***************
*** 760,765 ****
Value value = null;
if (collectType!=null) {
! Collection collection = collectType.create(subnode, path, model, root);
! root.addCollection(collection);
value = new Value(table);
bindValue(subnode, value, true);
--- 758,763 ----
Value value = null;
if (collectType!=null) {
! Collection collection = collectType.create(subnode, path, model, mappings);
! mappings.addCollection(collection);
value = new Value(table);
bindValue(subnode, value, true);
***************
*** 781,797 ****
Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType();
value = new Component(model);
! bindComponent(subnode, (Component) value, reflectedClass, path, true, root);
}
! else if ( "subclass".equals(name) || "joined-subclass".equals(name) ) {
Subclass subclass = new Subclass(model);
! bindSubclass( list.item(i), subclass, root );
model.addSubclass(subclass);
! root.addPersistentClass(subclass);
}
if ( value!=null) {
value.setTypeByReflection( model.getPersistentClass(), propertyName );
value.createForeignKey();
Property prop = new Property();
! bindProperty(subnode, prop, value, root);
model.addProperty(prop);
}
--- 779,801 ----
Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType();
value = new Component(model);
! bindComponent(subnode, (Component) value, reflectedClass, path, true, mappings);
}
! else if ( "subclass".equals(name) ) {
Subclass subclass = new Subclass(model);
! bindSubclass( list.item(i), subclass, mappings );
model.addSubclass(subclass);
! mappings.addClass(subclass);
}
+ else if ( "joined-subclass".equals(name) ) {
+ Subclass subclass = new Subclass(model);
+ bindJoinedSubclass( list.item(i), subclass, mappings );
+ model.addSubclass(subclass);
+ mappings.addClass(subclass);
+ }
if ( value!=null) {
value.setTypeByReflection( model.getPersistentClass(), propertyName );
value.createForeignKey();
Property prop = new Property();
! bindProperty(subnode, prop, value, mappings);
model.addProperty(prop);
}
***************
*** 799,819 ****
}
! public static void bindSetSecondPass(Set model, java.util.Map persistentClasses) throws MappingException {
! if (model.doneSecondPass) return;
!
! bindCollectionSecondPass(model, persistentClasses);
if ( !model.isOneToMany() ) model.createPrimaryKey();
}
!
! public static void bindListSecondPass(List model, java.util.Map classes) throws MappingException {
!
! if (model.doneSecondPass) return;
! bindCollectionSecondPass(model, classes);
! NodeList list = model.node.getChildNodes();
for ( int i=0; i<list.getLength(); i++ ) {
Node subnode = list.item(i);
--- 803,822 ----
}
! public static void bindSetSecondPass(Node node, Set model, java.util.Map persistentClasses, Mappings mappings) throws MappingException {
! bindCollectionSecondPass(node, model, persistentClasses, mappings);
if ( !model.isOneToMany() ) model.createPrimaryKey();
}
!
! /**
! * Called for Lists, arrays, primitive arrays
! */
! public static void bindListSecondPass(Node node, List model, java.util.Map classes, Mappings mappings) throws MappingException {
! bindCollectionSecondPass(node, model, classes, mappings);
! NodeList list = node.getChildNodes();
for ( int i=0; i<list.getLength(); i++ ) {
Node subnode = list.item(i);
***************
*** 828,841 ****
if ( !model.isOneToMany() ) model.createPrimaryKey();
- model.doneSecondPass = true;
}
! public static void bindMapSecondPass(Map model, java.util.Map classes) throws MappingException {
!
! if (model.doneSecondPass) return;
! bindCollectionSecondPass(model, classes);
! NodeList list = model.node.getChildNodes();
for ( int i=0; i<list.getLength(); i++ ) {
Node subnode = list.item(i);
--- 831,844 ----
if ( !model.isOneToMany() ) model.createPrimaryKey();
}
! /**
! * Called for Maps
! */
! public static void bindMapSecondPass(Node node, Map model, java.util.Map classes, Mappings mappings) throws MappingException {
! bindCollectionSecondPass(node, model, classes, mappings);
! NodeList list = node.getChildNodes();
for ( int i=0; i<list.getLength(); i++ ) {
Node subnode = list.item(i);
***************
*** 856,860 ****
else if ( "composite-index".equals(name) ) {
Component component = new Component( model.getTable() );
! bindComponent(subnode, component, null, Root.ROOT_ROLE_NAME, model.isOneToMany(), model.root);
model.setIndex(component);
}
--- 859,863 ----
else if ( "composite-index".equals(name) ) {
Component component = new Component( model.getTable() );
! bindComponent(subnode, component, null, Mappings.ROOT_ROLE_NAME, model.isOneToMany(), mappings);
model.setIndex(component);
}
***************
*** 864,874 ****
if ( !model.isOneToMany() ) model.createPrimaryKey();
- model.doneSecondPass = true;
}
!
! public static void bindCollectionSecondPass(Collection model, java.util.Map persistentClasses) throws MappingException {
- if (model.doneSecondPass) return;
-
if ( model.isOneToMany() ) {
Class assocClass = model.getOneToMany().getType().getPersistentClass();
--- 867,877 ----
if ( !model.isOneToMany() ) model.createPrimaryKey();
}
!
! /**
! * Called for all collections
! */
! public static void bindCollectionSecondPass(Node node, Collection model, java.util.Map persistentClasses, Mappings mappings) throws MappingException {
if ( model.isOneToMany() ) {
Class assocClass = model.getOneToMany().getType().getPersistentClass();
***************
*** 880,884 ****
}
! NodeList list = model.node.getChildNodes();
for ( int i=0; i<list.getLength(); i++ ) {
Node subnode = list.item(i);
--- 883,887 ----
}
! NodeList list = node.getChildNodes();
for ( int i=0; i<list.getLength(); i++ ) {
Node subnode = list.item(i);
***************
*** 907,914 ****
Component element = new Component( model.getTable() );
model.setElement(element);
! bindComponent(subnode, element, null, Root.ROOT_ROLE_NAME, true, model.root);
}
else if ( "jcs-cache".equals(name) ) {
! model.setCache( model.root.createJCSCache(
subnode.getAttributes().getNamedItem("usage").getNodeValue(),
model.getRole(),
--- 910,917 ----
Component element = new Component( model.getTable() );
model.setElement(element);
! bindComponent(subnode, element, null, Mappings.ROOT_ROLE_NAME, true, mappings);
}
else if ( "jcs-cache".equals(name) ) {
! model.setCache( mappings.createJCSCache(
subnode.getAttributes().getNamedItem("usage").getNodeValue(),
model.getRole(),
***************
*** 927,934 ****
if ( !model.isIndexed() ) model.createIndex();
- model.doneSecondPass=true;
}
! public static void bindRoot(Document doc, Root model) throws MappingException {
Node hmNode = doc.getElementsByTagName("hibernate-mapping").item(0);
Node schemaNode = hmNode.getAttributes().getNamedItem("schema");
--- 930,937 ----
if ( !model.isIndexed() ) model.createIndex();
}
! public static void bindRoot(Document doc, Mappings model) throws MappingException {
!
Node hmNode = doc.getElementsByTagName("hibernate-mapping").item(0);
Node schemaNode = hmNode.getAttributes().getNamedItem("schema");
***************
*** 945,950 ****
RootClass rootclass = new RootClass();
Binder.bindRootClass(n, rootclass, model);
! log.debug("Root class: " + rootclass.getName() + " -> " + rootclass.getTable().getName() );
! model.addPersistentClass(rootclass);
}
else if ( name.equals("query") ) {
--- 948,953 ----
RootClass rootclass = new RootClass();
Binder.bindRootClass(n, rootclass, model);
! log.debug("Mapping class: " + rootclass.getName() + " -> " + rootclass.getTable().getName() );
! model.addClass(rootclass);
}
else if ( name.equals("query") ) {
***************
*** 957,967 ****
}
}
//This inner class implements a case statement....perhaps im being a bit over-clever here
! public static abstract class CollectionType {
private String xmlTag;
! public abstract Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException;
CollectionType(String xmlTag) {
this.xmlTag = xmlTag;
--- 960,1021 ----
}
+ }
+
+ static abstract class SecondPass {
+ Node node;
+ Mappings mappings;
+ Collection collection;
+ SecondPass(Node node, Mappings mappings, Collection collection) {
+ this.node = node;
+ this.collection = collection;
+ this.mappings = mappings;
+ }
+ abstract void secondPass(java.util.Map persistentClasses) throws MappingException;
+ }
+
+ static class CollectionSecondPass extends SecondPass {
+ CollectionSecondPass(Node node, Mappings mappings, Collection collection) {
+ super(node, mappings, collection);
+ }
+ void secondPass(java.util.Map persistentClasses) throws MappingException {
+ Binder.bindCollectionSecondPass( node, collection, persistentClasses, mappings );
+ }
+
+ }
+
+ static class MapSecondPass extends SecondPass {
+ MapSecondPass(Node node, Mappings mappings, Map collection) {
+ super(node, mappings, collection);
+ }
+ void secondPass(java.util.Map persistentClasses) throws MappingException {
+ Binder.bindMapSecondPass( node, (Map) collection, persistentClasses, mappings );
+ }
+
}
+ static class SetSecondPass extends SecondPass {
+ SetSecondPass(Node node, Mappings mappings, Set collection) {
+ super(node, mappings, collection);
+ }
+ void secondPass(java.util.Map persistentClasses) throws MappingException {
+ Binder.bindSetSecondPass( node, (Set) collection, persistentClasses, mappings );
+ }
+
+ }
+
+ static class ListSecondPass extends SecondPass {
+ ListSecondPass(Node node, Mappings mappings, List collection) {
+ super(node, mappings, collection);
+ }
+ void secondPass(java.util.Map persistentClasses) throws MappingException {
+ Binder.bindListSecondPass( node, (List) collection, persistentClasses, mappings );
+ }
+
+ }
//This inner class implements a case statement....perhaps im being a bit over-clever here
! static abstract class CollectionType {
private String xmlTag;
! public abstract Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException;
CollectionType(String xmlTag) {
this.xmlTag = xmlTag;
***************
*** 971,1012 ****
}
private static final CollectionType MAP = new CollectionType("map") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
Map map = new Map(owner);
! Binder.bindCollection(node, map, prefix, root);
return map;
}
};
private static final CollectionType SET = new CollectionType("set") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
Set set = new Set(owner);
! Binder.bindCollection(node, set, prefix, root);
return set;
}
};
private static final CollectionType LIST = new CollectionType("list") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
List list = new List(owner);
! Binder.bindCollection(node, list, prefix, root);
return list;
}
};
private static final CollectionType BAG = new CollectionType("bag") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
Bag bag = new Bag(owner);
! Binder.bindCollection(node, bag, prefix, root);
return bag;
}
};
private static final CollectionType ARRAY = new CollectionType("array") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
Array array = new Array(owner);
! Binder.bindArray(node, array, prefix, root);
return array;
}
};
private static final CollectionType PRIMITIVE_ARRAY = new CollectionType("primitive-array") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
PrimitiveArray array = new PrimitiveArray(owner);
! Binder.bindArray(node, array, prefix, root);
return array;
}
--- 1025,1066 ----
}
private static final CollectionType MAP = new CollectionType("map") {
! public Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException {
Map map = new Map(owner);
! Binder.bindCollection(node, map, prefix, mappings);
return map;
}
};
private static final CollectionType SET = new CollectionType("set") {
! public Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException {
Set set = new Set(owner);
! Binder.bindCollection(node, set, prefix, mappings);
return set;
}
};
private static final CollectionType LIST = new CollectionType("list") {
! public Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException {
List list = new List(owner);
! Binder.bindCollection(node, list, prefix, mappings);
return list;
}
};
private static final CollectionType BAG = new CollectionType("bag") {
! public Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException {
Bag bag = new Bag(owner);
! Binder.bindCollection(node, bag, prefix, mappings);
return bag;
}
};
private static final CollectionType ARRAY = new CollectionType("array") {
! public Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException {
Array array = new Array(owner);
! Binder.bindArray(node, array, prefix, mappings);
return array;
}
};
private static final CollectionType PRIMITIVE_ARRAY = new CollectionType("primitive-array") {
! public Collection create(Node node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException {
PrimitiveArray array = new PrimitiveArray(owner);
! Binder.bindArray(node, array, prefix, mappings);
return array;
}
Index: Configuration.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Configuration.java 27 Jan 2003 07:12:03 -0000 1.7
--- Configuration.java 27 Jan 2003 12:12:40 -0000 1.8
***************
*** 34,47 ****
import net.sf.hibernate.id.PersistentIdentifierGenerator;
import net.sf.hibernate.impl.SessionFactoryImpl;
- import net.sf.hibernate.mapping.Array;
- import net.sf.hibernate.mapping.Bag;
import net.sf.hibernate.mapping.ForeignKey;
import net.sf.hibernate.mapping.Index;
- import net.sf.hibernate.mapping.List;
- import net.sf.hibernate.mapping.Map;
import net.sf.hibernate.mapping.PersistentClass;
- import net.sf.hibernate.mapping.PrimitiveArray;
- import net.sf.hibernate.mapping.Root;
- import net.sf.hibernate.mapping.Set;
import net.sf.hibernate.mapping.Table;
import net.sf.hibernate.dialect.Dialect;
--- 34,40 ----
***************
*** 70,73 ****
--- 63,67 ----
private HashMap tables = new HashMap();
private HashMap namedQueries = new HashMap();
+ private ArrayList secondPasses = new ArrayList();
private Interceptor interceptor = EMPTY_INTERCEPTOR;
private Properties properties = Environment.getProperties();
***************
*** 160,164 ****
private void add(Document doc) throws Exception {
try {
! Binder.bindRoot( doc, createRoot() );
}
catch (MappingException me) {
--- 154,158 ----
private void add(Document doc) throws Exception {
try {
! Binder.bindRoot( doc, createMappings() );
}
catch (MappingException me) {
***************
*** 168,173 ****
}
! public Root createRoot() {
! return new Root(classes, collections, tables, namedQueries);
}
--- 162,171 ----
}
! /**
! * Create a new <tt>Mappings</tt> to add class and collection
! * mappings to.
! */
! public Mappings createMappings() {
! return new Mappings(classes, collections, tables, namedQueries, secondPasses);
}
***************
*** 413,425 ****
private void secondPassCompile() throws MappingException {
! Iterator iter = collections.values().iterator();
while ( iter.hasNext() ) {
! Object coll = iter.next();
! if (coll instanceof Set) Binder.bindSetSecondPass( (Set) coll, classes );
! if (coll instanceof Map) Binder.bindMapSecondPass( (Map) coll, classes );
! if (coll instanceof List) Binder.bindListSecondPass( (List) coll, classes );
! if (coll instanceof Bag) Binder.bindCollectionSecondPass( (Bag) coll, classes );
! if (coll instanceof Array) Binder.bindListSecondPass( (Array) coll, classes );
! if (coll instanceof PrimitiveArray) Binder.bindListSecondPass( (PrimitiveArray) coll, classes );
}
--- 411,419 ----
private void secondPassCompile() throws MappingException {
! Iterator iter = secondPasses.iterator();
while ( iter.hasNext() ) {
! Binder.SecondPass sp = (Binder.SecondPass) iter.next();
! sp.secondPass(classes);
! iter.remove();
}
***************
*** 432,436 ****
while ( subIter.hasNext() ) {
! ForeignKey fk = (ForeignKey)subIter.next();
if ( fk.getReferencedTable() == null ) {
PersistentClass referencedClass = (PersistentClass) classes.get( fk.getReferencedClass() );
--- 426,430 ----
while ( subIter.hasNext() ) {
! ForeignKey fk = (ForeignKey) subIter.next();
if ( fk.getReferencedTable() == null ) {
PersistentClass referencedClass = (PersistentClass) classes.get( fk.getReferencedClass() );
***************
*** 454,458 ****
private static final Interceptor EMPTY_INTERCEPTOR = new EmptyInterceptor();
! public static final class EmptyInterceptor implements Interceptor, Serializable {
/**
* @see net.sf.hibernate.Interceptor#onDelete(Object, Serializable id, Object[], String[], Type[])
--- 448,452 ----
private static final Interceptor EMPTY_INTERCEPTOR = new EmptyInterceptor();
! static final class EmptyInterceptor implements Interceptor, Serializable {
/**
* @see net.sf.hibernate.Interceptor#onDelete(Object, Serializable id, Object[], String[], Type[])
|
|
From: <one...@us...> - 2003-01-27 07:30:27
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers
In directory sc8-pr-cvs1:/tmp/cvs-serv30859/hibernate/helpers
Modified Files:
ReflectHelper.java
Log Message:
removed unnecessary test
Index: ReflectHelper.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/ReflectHelper.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** ReflectHelper.java 13 Jan 2003 13:05:45 -0000 1.39
--- ReflectHelper.java 27 Jan 2003 07:30:24 -0000 1.40
***************
*** 208,212 ****
for (int i=0; i<methods.length; i++) {
// only carry on if the method has no parameters
! if(methods[i].getParameterTypes().length==0) {
// try "get"
--- 208,212 ----
for (int i=0; i<methods.length; i++) {
// only carry on if the method has no parameters
! if( methods[i].getParameterTypes().length==0 ) {
// try "get"
***************
*** 215,222 ****
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) );
String testOldMethod = methods[i].getName().substring(3);
! if(
! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) &&
! methods[i].getParameterTypes().length==0
! ) return methods[i];
}
--- 215,219 ----
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) );
String testOldMethod = methods[i].getName().substring(3);
! if( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) return methods[i];
}
***************
*** 227,234 ****
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) );
String testOldMethod = methods[i].getName().substring(2);
! if(
! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) &&
! methods[i].getParameterTypes().length==0
! ) return methods[i];
}
}
--- 224,228 ----
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) );
String testOldMethod = methods[i].getName().substring(2);
! if( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) return methods[i];
}
}
|
|
From: <one...@us...> - 2003-01-27 07:27:47
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util
In directory sc8-pr-cvs1:/tmp/cvs-serv29813/hibernate/util
Modified Files:
ReflectHelper.java
Log Message:
removed unnecessary test
Index: ReflectHelper.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/ReflectHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ReflectHelper.java 13 Jan 2003 13:03:51 -0000 1.5
--- ReflectHelper.java 27 Jan 2003 07:27:44 -0000 1.6
***************
*** 212,222 ****
// try "get"
if( (methods[i].getName().length() > 3) && methods[i].getName().startsWith("get") ) {
-
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) );
String testOldMethod = methods[i].getName().substring(3);
! if(
! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) &&
! methods[i].getParameterTypes().length==0
! ) return methods[i];
}
--- 212,218 ----
// try "get"
if( (methods[i].getName().length() > 3) && methods[i].getName().startsWith("get") ) {
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(3) );
String testOldMethod = methods[i].getName().substring(3);
! if( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) return methods[i];
}
***************
*** 224,234 ****
// if not "get" then try "is"
if( (methods[i].getName().length() > 2) && methods[i].getName().startsWith("is") ) {
-
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) );
String testOldMethod = methods[i].getName().substring(2);
! if(
! ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) &&
! methods[i].getParameterTypes().length==0
! ) return methods[i];
}
}
--- 220,226 ----
// if not "get" then try "is"
if( (methods[i].getName().length() > 2) && methods[i].getName().startsWith("is") ) {
String testStdMethod = Introspector.decapitalize( methods[i].getName().substring(2) );
String testOldMethod = methods[i].getName().substring(2);
! if( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) return methods[i];
}
}
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping
In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/mapping
Modified Files:
Array.java Association.java Bag.java Collection.java
Column.java Component.java Index.java IndexedCollection.java
IntegerValue.java List.java ManyToOne.java Map.java
OneToMany.java OneToOne.java PersistentClass.java
PrimitiveArray.java Property.java Root.java RootClass.java
Set.java Subclass.java Value.java
Log Message:
massive refactoring of XML mapping parsing code
Index: Array.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Array.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Array.java 19 Jan 2003 11:47:07 -0000 1.5
--- Array.java 27 Jan 2003 07:12:03 -0000 1.6
***************
*** 2,54 ****
package net.sf.hibernate.mapping;
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.type.PersistentCollectionType;
- import net.sf.hibernate.type.PrimitiveType;
- import net.sf.hibernate.type.Type;
import net.sf.hibernate.type.TypeFactory;
- import net.sf.hibernate.util.ReflectHelper;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
public class Array extends List {
private Class elementClass;
! public Array(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! super(node, prefix, owner, root);
! Node att = node.getAttributes().getNamedItem("element-class");
! if ( att!=null ) {
! try {
! elementClass = ReflectHelper.classForName( att.getNodeValue() );
! }
! catch (ClassNotFoundException cnfe) {
! throw new MappingException(cnfe);
! }
! }
! else {
!
! NodeList list = node.getChildNodes();
! for ( int i=0; i<list.getLength(); i++ ) {
! Node subnode = list.item(i);
! String name = subnode.getNodeName();
!
! if ( "element".equals(name) ) {
! Type type = Value.getTypeFromXML(subnode);
! elementClass = isPrimitiveArray() ? ( (PrimitiveType) type ).primitiveClass() : type.getReturnedClass();
! }
! else if ( "one-to-many".equals(name) || "many-to-many".equals(name) || "composite-element".equals(name) ) {
! try {
! elementClass = ReflectHelper.classForName( subnode.getAttributes().getNamedItem("class").getNodeValue() );
! }
! catch (ClassNotFoundException cnfe) {
! throw new MappingException(cnfe);
! }
! }
!
! }
! }
!
}
!
public Class getElementClass() {
return elementClass;
--- 2,20 ----
package net.sf.hibernate.mapping;
import net.sf.hibernate.type.PersistentCollectionType;
import net.sf.hibernate.type.TypeFactory;
public class Array extends List {
private Class elementClass;
! /**
! * Constructor for Array.
! * @param owner
! */
! public Array(PersistentClass owner) {
! super(owner);
}
!
public Class getElementClass() {
return elementClass;
***************
*** 67,70 ****
--- 33,44 ----
}
+ /**
+ * Sets the elementClass.
+ * @param elementClass The elementClass to set
+ */
+ public void setElementClass(Class elementClass) {
+ this.elementClass = elementClass;
+ }
+
}
Index: Association.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Association.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Association.java 19 Jan 2003 11:47:07 -0000 1.6
--- Association.java 27 Jan 2003 07:12:03 -0000 1.7
***************
*** 3,46 ****
import net.sf.hibernate.MappingException;
- import net.sf.hibernate.loader.OuterJoinLoader;
- import net.sf.hibernate.type.Type;
-
- import org.w3c.dom.Node;
public abstract class Association extends Value {
! private final int joinedFetch;
! private int initJoinedFetch(Node node) {
! Node jfNode = node.getAttributes().getNamedItem("outer-join");
! if ( jfNode==null ) {
! return OuterJoinLoader.AUTO;
! }
! else {
! String eoj = jfNode.getNodeValue().toLowerCase();
! if ( "auto".equals(eoj) ) return OuterJoinLoader.AUTO;
! return "true".equals(eoj) ? OuterJoinLoader.EAGER : OuterJoinLoader.LAZY;
! }
}
!
! // 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);
}
! // A many-to-one association
! protected Association(Node node, String path, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, isNullable, table, root, defaultColumnName);
! joinedFetch = initJoinedFetch(node);
}
- protected abstract Type typeFromXML(Node node) throws MappingException;
-
public abstract void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException;
!
! public int enableJoinedFetch() { return joinedFetch; }
!
! public abstract void createForeignKeys(Root root, Table table);
}
--- 3,25 ----
import net.sf.hibernate.MappingException;
public abstract class Association extends Value {
! private int joinedFetch;
! protected Association(Table table) {
! super(table);
}
!
! public int getOuterJoinFetchSetting() {
! return joinedFetch;
}
! public void setOuterJoinFetchSetting(int joinedFetch) {
! this.joinedFetch=joinedFetch;
}
public abstract void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException;
! public abstract void createForeignKey();
}
Index: Bag.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Bag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Bag.java 5 Jan 2003 02:11:22 -0000 1.3
--- Bag.java 27 Jan 2003 07:12:03 -0000 1.4
***************
*** 2,8 ****
package net.sf.hibernate.mapping;
- import org.w3c.dom.Node;
-
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.type.PersistentCollectionType;
import net.sf.hibernate.type.TypeFactory;
--- 2,5 ----
***************
*** 10,18 ****
public class Bag extends Collection {
! public Bag(Node node, String prefix, PersistentClass owner, Root root)
! throws MappingException {
! super(node, prefix, owner, root);
}
!
public PersistentCollectionType getType() {
return TypeFactory.bag( getRole() );
--- 7,18 ----
public class Bag extends Collection {
! /**
! * Constructor for Bag.
! * @param owner
! */
! public Bag(PersistentClass owner) {
! super(owner);
}
!
public PersistentCollectionType getType() {
return TypeFactory.bag( getRole() );
***************
*** 23,26 ****
--- 23,30 ----
}
+ public void createPrimaryKey() {
+ //do nothing .. bags have no PK
+ }
+
}
Index: Collection.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Collection.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Collection.java 26 Jan 2003 01:33:35 -0000 1.9
--- Collection.java 27 Jan 2003 07:12:03 -0000 1.10
***************
*** 2,31 ****
package net.sf.hibernate.mapping;
import java.util.Iterator;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
- import net.sf.hibernate.cfg.Environment;
- import net.sf.hibernate.util.StringHelper;
import net.sf.hibernate.type.PersistentCollectionType;
public abstract class Collection {
! private static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";
! private static final String DEFAULT_KEY_COLUMN_NAME = "id";
!
! private static final Log log = LogFactory.getLog(Collection.class);
- // All can be made final except table
private Value key;
private Value element;
private Table table;
! private final String role;
private boolean lazy;
private boolean isOneToMany;
--- 2,22 ----
package net.sf.hibernate.mapping;
+ import java.util.Comparator;
import java.util.Iterator;
import org.w3c.dom.Node;
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.type.PersistentCollectionType;
public abstract class Collection {
! public static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";
! public static final String DEFAULT_KEY_COLUMN_NAME = "id";
private Value key;
private Value element;
private Table table;
! private String role;
private boolean lazy;
private boolean isOneToMany;
***************
*** 34,41 ****
private CacheConcurrencyStrategy cache;
private String orderBy;
- protected Node node;
private PersistentClass owner;
! protected Root root;
! private boolean doneSecondPass;
public boolean isSet() {
--- 25,41 ----
private CacheConcurrencyStrategy cache;
private String orderBy;
private PersistentClass owner;
!
! //TODO: remove these ugly instance vars
! public Node node;
! public Root root;
! public boolean doneSecondPass;
!
! private boolean sorted;
! private Comparator comparator;
!
! protected Collection(PersistentClass owner) {
! this.owner = owner;
! }
public boolean isSet() {
***************
*** 62,173 ****
this.table = table;
}
! public Collection(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! this.node = node;
! this.owner = owner;
! this.root = root;
! 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;
!
! Node inverseNode = atts.getNamedItem("inverse");
! if ( inverseNode==null) inverseNode = atts.getNamedItem("readonly");
! if ( inverseNode!=null) inverse = StringHelper.booleanValue( inverseNode.getNodeValue() );
!
! Node orderNode = atts.getNamedItem("order-by");
! if ( orderNode!=null) {
! if ( Environment.jvmSupportsLinkedHashCollections() || ( this instanceof Bag ) ) {
! orderBy = orderNode.getNodeValue();
! }
! else {
! log.warn("Attribute \"order-by\" ignored in JDK1.3 or less");
! }
! }
!
! NodeList list = node.getChildNodes();
! for ( int i=0; i<list.getLength(); i++ ) {
! String name = list.item(i).getNodeName();
! if ( "one-to-many".equals(name) ) {
! isOneToMany = true;
! oneToMany = new OneToMany( list.item(i), owner );
! }
! }
! if (isOneToMany) {
! //we have to set up the table later!! yuck
! }
! else {
! //TABLE
! Node tableNode = atts.getNamedItem("table");
! String tableName;
! if (tableNode!=null) {
! tableName = tableNode.getNodeValue();
! }
! else {
! tableName = barerole;
! }
! Node schemaNode = atts.getNamedItem("schema");
! String schema = schemaNode==null ? root.getSchemaName() : schemaNode.getNodeValue();
! table = root.addTable(schema, tableName);
! }
! //LAZINESS
! Node lazyNode = atts.getNamedItem("lazy");
! if (lazyNode!=null) {
! lazy = StringHelper.booleanValue( lazyNode.getNodeValue() );
! }
!
}
!
! public void secondPassCompile(java.util.Map persistentClasses) throws MappingException {
! if (doneSecondPass) return;
!
! if (isOneToMany) {
! Class assocClass = getOneToMany().getType().getPersistentClass();
! PersistentClass persistentClass = (PersistentClass) persistentClasses.get(assocClass);
! if (persistentClass==null) throw new MappingException(
! "Association references unmapped class: " + assocClass.getName()
! );
! table = persistentClass.getTable();
! }
!
! NodeList list = node.getChildNodes();
! for ( int i=0; i<list.getLength(); i++ ) {
! Node subnode = list.item(i);
! String name = subnode.getNodeName();
!
! if ( "key".equals(name) || "generated-key".equals(name) ) {
! key = new Value(subnode, isOneToMany, table, root, DEFAULT_KEY_COLUMN_NAME);
! key.setType( owner.getIdentifier().getType() );
! if ( key.getType().getReturnedClass().isArray() ) throw new MappingException(
! "illegal use of an array as an identifier (arrays don't reimplement equals)"
! );
! }
! else if ( "element".equals(name) ) {
! element = new Value(subnode, true, table, root, DEFAULT_ELEMENT_COLUMN_NAME);
! }
! else if ( "many-to-many".equals(name) ) {
! element = new ManyToOne(subnode, Root.ROOT_ROLE_NAME, DEFAULT_ELEMENT_COLUMN_NAME, true, table, root);
! }
! else if ( "composite-element".equals(name) ) {
! element = new Component(subnode, null, Root.ROOT_ROLE_NAME, null, true, table, root);
! }
! else if ( "jcs-cache".equals(name) ) {
! cache = root.createJCSCache(subnode, role, owner);
! }
! }
!
! if (!inverse) {
! if (!isOneToMany) element.createForeignKeys(root, table);
! // no foreign key for a one-to-many
!
! key.createForeignKeyOfClass( root, table, owner.getPersistentClass() );
! }
!
! if ( !isIndexed() ) createIndex();
!
! doneSecondPass=true;
}
-
public boolean isLazy() {
return lazy;
--- 62,71 ----
this.table = table;
}
! public boolean isSorted() {
! return sorted;
}
! public Comparator getComparator() {
! return comparator;
}
public boolean isLazy() {
return lazy;
***************
*** 207,213 ****
return index;
}
! public void createPrimaryKey() {
! // do nothing
! }
public CacheConcurrencyStrategy getCache() {
--- 105,109 ----
return index;
}
! public abstract void createPrimaryKey();
public CacheConcurrencyStrategy getCache() {
***************
*** 223,226 ****
--- 119,226 ----
}
+ /**
+ * Returns the orderBy.
+ * @return String
+ */
+ public String getOrderBy() {
+ return orderBy;
+ }
+
+ /**
+ * Sets the cache.
+ * @param cache The cache to set
+ */
+ public void setCache(CacheConcurrencyStrategy cache) {
+ this.cache = cache;
+ }
+
+ /**
+ * Sets the comparator.
+ * @param comparator The comparator to set
+ */
+ public void setComparator(Comparator comparator) {
+ this.comparator = comparator;
+ }
+
+ /**
+ * Sets the element.
+ * @param element The element to set
+ */
+ public void setElement(Value element) {
+ this.element = element;
+ }
+
+ /**
+ * Sets the isOneToMany.
+ * @param isOneToMany The isOneToMany to set
+ */
+ public void setIsOneToMany(boolean isOneToMany) {
+ this.isOneToMany = isOneToMany;
+ }
+
+ /**
+ * Sets the key.
+ * @param key The key to set
+ */
+ public void setKey(Value key) {
+ this.key = key;
+ }
+
+ /**
+ * Sets the oneToMany.
+ * @param oneToMany The oneToMany to set
+ */
+ public void setOneToMany(OneToMany oneToMany) {
+ this.oneToMany = oneToMany;
+ }
+
+ /**
+ * Sets the orderBy.
+ * @param orderBy The orderBy to set
+ */
+ public void setOrderBy(String orderBy) {
+ this.orderBy = orderBy;
+ }
+
+ /**
+ * Sets the role.
+ * @param role The role to set
+ */
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ /**
+ * Sets the sorted.
+ * @param sorted The sorted to set
+ */
+ public void setSorted(boolean sorted) {
+ this.sorted = sorted;
+ }
+
+ /**
+ * Sets the inverse.
+ * @param inverse The inverse to set
+ */
+ public void setInverse(boolean inverse) {
+ this.inverse = inverse;
+ }
+
+ /**
+ * Returns the owner.
+ * @return PersistentClass
+ */
+ public PersistentClass getOwner() {
+ return owner;
+ }
+
+ /**
+ * Sets the owner.
+ * @param owner The owner to set
+ */
+ public void setOwner(PersistentClass owner) {
+ this.owner = owner;
+ }
+
}
Index: Column.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Column.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Column.java 19 Jan 2003 11:47:07 -0000 1.4
--- Column.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 7,13 ****
import net.sf.hibernate.engine.Mapping;
import net.sf.hibernate.type.Type;
- import net.sf.hibernate.util.StringHelper;
-
- import org.w3c.dom.Node;
public class Column {
--- 7,10 ----
***************
*** 55,70 ****
}
- public Column(Node node, boolean isNullable, Type type, int typeIndex) {
- this(type, typeIndex);
- Node lengthNode = node.getAttributes().getNamedItem("length");
- if (lengthNode!=null) length = Integer.parseInt( lengthNode.getNodeValue() );
- Node nullNode = node.getAttributes().getNamedItem("not-null");
- nullable = (nullNode!=null) ? !StringHelper.booleanValue( nullNode.getNodeValue() ) : isNullable;
- Node unqNode = node.getAttributes().getNamedItem("unique");
- unique = unqNode!=null && StringHelper.booleanValue( unqNode.getNodeValue() );
- Node typeNode = node.getAttributes().getNamedItem("sql-type");
- sqlType = (typeNode==null) ? null : typeNode.getNodeValue();
- }
-
public int getTypeIndex() {
return typeIndex;
--- 52,55 ----
***************
*** 109,112 ****
--- 94,121 ----
return name.hashCode();
}
+ /**
+ * Returns the sqlType.
+ * @return String
+ */
+ public String getSqlType() {
+ return sqlType;
+ }
+
+ /**
+ * Sets the sqlType.
+ * @param sqlType The sqlType to set
+ */
+ public void setSqlType(String sqlType) {
+ this.sqlType = sqlType;
+ }
+
+ /**
+ * Sets the unique.
+ * @param unique The unique to set
+ */
+ public void setUnique(boolean unique) {
+ this.unique = unique;
+ }
+
}
Index: Component.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Component.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Component.java 19 Jan 2003 11:47:07 -0000 1.6
--- Component.java 27 Jan 2003 07:12:03 -0000 1.7
***************
*** 6,22 ****
import net.sf.hibernate.MappingException;
- import net.sf.hibernate.engine.Cascades;
- import net.sf.hibernate.type.Type;
import net.sf.hibernate.util.JoinedIterator;
- import net.sf.hibernate.util.ReflectHelper;
- import net.sf.hibernate.util.StringHelper;
- import net.sf.hibernate.type.ComponentType;
- import net.sf.hibernate.type.DynaBeanType;
import org.apache.commons.beanutils.BasicDynaClass;
- import org.apache.commons.beanutils.BasicDynaBean;
- import org.apache.commons.beanutils.DynaProperty;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
public class Component extends Value {
--- 6,12 ----
***************
*** 25,30 ****
private Class componentClass;
private BasicDynaClass dynaClass;
! private final boolean embedded;
private String parentProperty;
public int getPropertySpan() {
--- 15,21 ----
private Class componentClass;
private BasicDynaClass dynaClass;
! private boolean embedded;
private String parentProperty;
+ private PersistentClass owner;
public int getPropertySpan() {
***************
*** 59,166 ****
}
! public Component(Node node, Class reflectedClass, String path, PersistentClass owner, boolean isNullable, Table table, Root root) throws MappingException {
! super();
! setTable(table);
! Node classNode = node.getAttributes().getNamedItem("class");
! Node dynaclassNode = node.getAttributes().getNamedItem("dynaclass");
! String className;
! if (dynaclassNode!=null) {
! className = dynaclassNode.getNodeValue();
! embedded = false;
! }
! else if (classNode!=null) {
! className = classNode.getNodeValue();
! try {
! componentClass = ReflectHelper.classForName(className);
! }
! catch (ClassNotFoundException cnfe) {
! throw new MappingException( "component class not found", cnfe );
! }
! embedded = false;
! }
! else if (reflectedClass!=null) {
! componentClass = reflectedClass;
! className = componentClass.getName();
! embedded = false;
! }
! else {
! // an "embedded" component (ids only)
! componentClass = owner.getPersistentClass();
! className = owner.getName();
! embedded = true;
! }
!
! //component path
! path += Root.ROLE_SEPERATOR + StringHelper.unqualify(className);
!
! NodeList list = node.getChildNodes();
! for ( int i=0; i<list.getLength(); i++ ) {
!
! Node subnode = list.item(i);
! String name = subnode.getNodeName();
! String propertyName = Property.getPropertyName(subnode);
!
! Root.CollectionType collectType = Root.CollectionType.collectionTypeFromString(name);
! Value value = null;
! if (collectType!=null) {
! 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) ) {
! value = new ManyToOne(subnode, path, propertyName, isNullable, table, root);
! }
! else if ( "one-to-one".equals(name) ) {
! value = new OneToOne(subnode, owner.getIdentifier(), path, isNullable, table, root);
! }
! else if ( "property".equals(name) || "key-property".equals(name) ) {
! value = new Value(subnode, isNullable, table, root, propertyName);
! }
! else if ( "collection".equals(name) ) {
! value = new Value(subnode, isNullable, table, root, propertyName);
! }
! else if ( "component".equals(name) || "dynabean".equals(name) || "nested-composite-element".equals(name) ) {
! Class subreflectedClass = (componentClass==null) ?
! null :
! ReflectHelper.getGetter( componentClass, propertyName ).getReturnType();
! value = new Component(subnode, subreflectedClass, path, owner, isNullable, table, root);
! }
! else if ( "parent".equals(name) ) {
! parentProperty = propertyName;
! }
! if ( value!=null) {
! if (componentClass!=null) value.setTypeByReflection(componentClass, propertyName);
! value.createForeignKeys(root, table);
! addProperty( new Property(subnode, value, root) );
! }
! }
!
! int span = getPropertySpan();
! String[] names = new String[span];
! Type[] types = new Type[span];
! Cascades.CascadeStyle[] cascade = new Cascades.CascadeStyle[span];
! int[] joinedFetch = new int[span];
! DynaProperty[] dynaprops = new DynaProperty[span];
! Iterator iter = getPropertyIterator();
! int i=0;
! while ( iter.hasNext() ) {
! Property prop = (Property) iter.next();
! names[i] = prop.getName();
! types[i] = prop.getType();
! cascade[i] = prop.cascade();
! joinedFetch[i] = prop.getValue().enableJoinedFetch();
! if (componentClass==null) dynaprops[i] = new DynaProperty( names[i], types[i].getReturnedClass() );
! i++;
! }
! if (componentClass==null) dynaClass = new BasicDynaClass(className, BasicDynaBean.class, dynaprops);
!
! setType(
! (componentClass==null) ?
! (Type) new DynaBeanType(dynaClass, names, types, joinedFetch, cascade) :
! (Type) new ComponentType(componentClass, names, types, joinedFetch, cascade, parentProperty, embedded)
! );
}
!
public void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException {
}
--- 50,63 ----
}
! public Component(PersistentClass owner) throws MappingException {
! super( owner.getTable() );
! this.owner = owner;
}
!
! public Component(Table table) throws MappingException {
! super(table);
! this.owner = null;
! }
!
public void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException {
}
***************
*** 174,177 ****
--- 71,154 ----
}
+ /**
+ * Returns the componentClass.
+ * @return Class
+ */
+ public Class getComponentClass() {
+ return componentClass;
+ }
+
+ /**
+ * Returns the dynaClass.
+ * @return BasicDynaClass
+ */
+ public BasicDynaClass getDynaClass() {
+ return dynaClass;
+ }
+
+ /**
+ * Returns the owner.
+ * @return PersistentClass
+ */
+ public PersistentClass getOwner() {
+ return owner;
+ }
+
+ /**
+ * Returns the parentProperty.
+ * @return String
+ */
+ public String getParentProperty() {
+ return parentProperty;
+ }
+
+ /**
+ * Returns the properties.
+ * @return ArrayList
+ */
+ public ArrayList getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets the componentClass.
+ * @param componentClass The componentClass to set
+ */
+ public void setComponentClass(Class componentClass) {
+ this.componentClass = componentClass;
+ }
+
+ /**
+ * Sets the dynaClass.
+ * @param dynaClass The dynaClass to set
+ */
+ public void setDynaClass(BasicDynaClass dynaClass) {
+ this.dynaClass = dynaClass;
+ }
+
+ /**
+ * Sets the embedded.
+ * @param embedded The embedded to set
+ */
+ public void setEmbedded(boolean embedded) {
+ this.embedded = embedded;
+ }
+
+ /**
+ * Sets the owner.
+ * @param owner The owner to set
+ */
+ public void setOwner(PersistentClass owner) {
+ this.owner = owner;
+ }
+
+ /**
+ * Sets the parentProperty.
+ * @param parentProperty The parentProperty to set
+ */
+ public void setParentProperty(String parentProperty) {
+ this.parentProperty = parentProperty;
+ }
+
}
Index: Index.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Index.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Index.java 20 Jan 2003 12:48:13 -0000 1.4
--- Index.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 11,24 ****
public class Index implements RelationalModel {
private Table table;
private ArrayList columns = new ArrayList();
private String name;
! public String sqlCreateString(Dialect dialect, Mapping p)
! throws HibernateException {
StringBuffer buf = new StringBuffer("create index ")
! .append( dialect.qualifyIndexName() ? name : StringHelper.unqualify(name) )
! .append(" on ")
! .append( table.getQualifiedName() )
! .append(" (");
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
--- 11,25 ----
public class Index implements RelationalModel {
+
private Table table;
private ArrayList columns = new ArrayList();
private String name;
!
! public String sqlCreateString(Dialect dialect, Mapping p) throws HibernateException {
StringBuffer buf = new StringBuffer("create index ")
! .append( dialect.qualifyIndexName() ? name : StringHelper.unqualify(name) )
! .append(" on ")
! .append( table.getQualifiedName() )
! .append(" (");
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
***************
*** 29,35 ****
--- 30,38 ----
return buf.toString();
}
+
public String sqlDropString(Dialect dialect) {
return "drop index " + table.getQualifiedName() + StringHelper.DOT + name;
}
+
public Table getTable() {
return table;
Index: IndexedCollection.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/IndexedCollection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** IndexedCollection.java 19 Jan 2003 11:47:07 -0000 1.4
--- IndexedCollection.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 4,21 ****
import java.util.Iterator;
- import net.sf.hibernate.MappingException;
-
- import org.w3c.dom.Node;
-
public abstract class IndexedCollection extends Collection {
! protected static final String DEFAULT_INDEX_COLUMN_NAME = "idx";
private Value index;
public Value getIndex() {
return index;
}
! void setIndex(Value index) {
this.index = index;
}
--- 4,25 ----
import java.util.Iterator;
public abstract class IndexedCollection extends Collection {
! public static final String DEFAULT_INDEX_COLUMN_NAME = "idx";
private Value index;
+ /**
+ * Constructor for IndexedCollection.
+ * @param owner
+ */
+ public IndexedCollection(PersistentClass owner) {
+ super(owner);
+ }
+
public Value getIndex() {
return index;
}
! public void setIndex(Value index) {
this.index = index;
}
***************
*** 23,29 ****
return true;
}
! public IndexedCollection(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! super(node, prefix, owner, root);
! }
public void createPrimaryKey() {
PrimaryKey pk = new PrimaryKey();
--- 27,32 ----
return true;
}
!
!
public void createPrimaryKey() {
PrimaryKey pk = new PrimaryKey();
Index: IntegerValue.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/IntegerValue.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** IntegerValue.java 19 Jan 2003 11:47:07 -0000 1.6
--- IntegerValue.java 27 Jan 2003 07:12:03 -0000 1.7
***************
*** 3,22 ****
import net.sf.hibernate.Hibernate;
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.type.Type;
- import org.w3c.dom.Node;
-
public class IntegerValue extends Value {
! public Type getType() {
! return Hibernate.INTEGER;
}
! public IntegerValue(Node node, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, isNullable, table, root, defaultColumnName);
! Column col = ( (Column) getColumnIterator().next() );
! col.setType( getType() );
! col.setTypeIndex(0);
}
--- 3,16 ----
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.type.Type;
public class IntegerValue extends Value {
! public IntegerValue(Table table) {
! super(table);
}
! public Type getType() {
! return Hibernate.INTEGER;
}
Index: List.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/List.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** List.java 19 Jan 2003 11:47:07 -0000 1.4
--- List.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 2,37 ****
package net.sf.hibernate.mapping;
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.type.PersistentCollectionType;
import net.sf.hibernate.type.TypeFactory;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
-
public class List extends IndexedCollection {
! private boolean doneSecondPass;
!
! public List(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! super(node, prefix, owner, root);
! }
!
! public void secondPassCompile(java.util.Map classes) throws MappingException {
! super.secondPassCompile(classes);
! if (doneSecondPass) return;
! NodeList list = node.getChildNodes();
! for ( int i=0; i<list.getLength(); i++ ) {
! Node subnode = list.item(i);
! String name = subnode.getNodeName();
!
! if ( "index".equals(name) ) {
! setIndex( new IntegerValue(subnode, DEFAULT_INDEX_COLUMN_NAME, isOneToMany(), getTable(), root) );
! }
! }
! if ( !isOneToMany() ) createPrimaryKey();
!
! doneSecondPass = true;
}
!
public PersistentCollectionType getType() {
return TypeFactory.list( getRole() );
--- 2,18 ----
package net.sf.hibernate.mapping;
import net.sf.hibernate.type.PersistentCollectionType;
import net.sf.hibernate.type.TypeFactory;
public class List extends IndexedCollection {
! /**
! * Constructor for List.
! * @param owner
! */
! public List(PersistentClass owner) {
! super(owner);
}
!
public PersistentCollectionType getType() {
return TypeFactory.list( getRole() );
Index: ManyToOne.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/ManyToOne.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ManyToOne.java 5 Jan 2003 02:11:22 -0000 1.4
--- ManyToOne.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 2,33 ****
package net.sf.hibernate.mapping;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
-
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.util.ReflectHelper;
import net.sf.hibernate.type.EntityType;
- import net.sf.hibernate.type.Type;
import net.sf.hibernate.type.TypeFactory;
public class ManyToOne extends Association {
! // A many-to-one association
! public ManyToOne(Node node, String path, String defaultColumnName, boolean isNullable, Table table, Root root) throws MappingException {
! super(node, path, defaultColumnName, isNullable, table, root);
! }
!
! protected Type typeFromXML(Node node) throws MappingException {
!
! NamedNodeMap atts = node.getAttributes();
! Node typeNode = atts.getNamedItem("class");
! if (typeNode==null) return null;
! try {
! return TypeFactory.manyToOne( ReflectHelper.classForName( typeNode.getNodeValue() ) );
! }
! catch (Exception e) {
! throw new MappingException("Could not find class: " + typeNode.getNodeValue());
! }
}
--- 2,15 ----
package net.sf.hibernate.mapping;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.util.ReflectHelper;
import net.sf.hibernate.type.EntityType;
import net.sf.hibernate.type.TypeFactory;
public class ManyToOne extends Association {
! public ManyToOne(Table table) throws MappingException {
! super(table);
}
***************
*** 43,48 ****
}
! public void createForeignKeys(Root root, Table table) {
! createForeignKeyOfClass(root, table, ( (EntityType) getType() ).getPersistentClass() );
}
--- 25,30 ----
}
! public void createForeignKey() {
! createForeignKeyOfClass( ( (EntityType) getType() ).getPersistentClass() );
}
Index: Map.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Map.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Map.java 19 Jan 2003 11:47:07 -0000 1.7
--- Map.java 27 Jan 2003 07:12:03 -0000 1.8
***************
*** 2,78 ****
package net.sf.hibernate.mapping;
- import java.util.Comparator;
-
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.type.PersistentCollectionType;
import net.sf.hibernate.type.TypeFactory;
- import net.sf.hibernate.util.ReflectHelper;
-
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
public class Map extends IndexedCollection {
! private final boolean sorted;
! private Comparator comparator;
! private boolean doneSecondPass;
!
! public Map(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! super(node, prefix, owner, root);
!
! Node sortedAtt = node.getAttributes().getNamedItem("sort");
!
! // unsorted, natural, comparator.class.name
! if (sortedAtt==null|| sortedAtt.getNodeValue().equals("unsorted") ) {
! sorted = false;
! }
! else {
! sorted = true;
! String className = sortedAtt.getNodeValue();
! if ( !className.equals("natural") ) {
! try {
! comparator = (Comparator) ReflectHelper.classForName(className).newInstance();
! }
! catch (Exception e) {
! throw new MappingException( "Could not instantiate comparator class: " + className );
! }
! }
! }
!
! }
!
! public void secondPassCompile(java.util.Map classes) throws MappingException {
! super.secondPassCompile(classes);
! if (doneSecondPass) return;
! NodeList list = node.getChildNodes();
! for ( int i=0; i<list.getLength(); i++ ) {
! Node subnode = list.item(i);
! String name = subnode.getNodeName();
!
! if ( "index".equals(name) ) {
! setIndex( new Value(subnode, isOneToMany(), getTable(), root, DEFAULT_INDEX_COLUMN_NAME) );
! if ( getIndex().getType()==null ) throw new MappingException("map index element must specify a type");
! }
! else if ( "index-many-to-many".equals(name) ) {
! setIndex( new ManyToOne(subnode, null, DEFAULT_INDEX_COLUMN_NAME, isOneToMany(), getTable(), root ) );
!
! }
! else if ( "composite-index".equals(name) ) {
! setIndex( new Component(subnode, null, Root.ROOT_ROLE_NAME, null, isOneToMany(), getTable(), root) );
! }
! }
! if ( !isInverse() ) getIndex().createForeignKeys( root, getTable() );
!
! if ( !isOneToMany() ) createPrimaryKey();
!
! doneSecondPass = true;
}
!
public PersistentCollectionType getType() {
! return sorted ? TypeFactory.sortedMap( getRole(), comparator ): TypeFactory.map( getRole() );
}
public Class wrapperClass() {
! return sorted ? net.sf.hibernate.collection.SortedMap.class : net.sf.hibernate.collection.Map.class;
}
--- 2,24 ----
package net.sf.hibernate.mapping;
import net.sf.hibernate.type.PersistentCollectionType;
import net.sf.hibernate.type.TypeFactory;
public class Map extends IndexedCollection {
! /**
! * Constructor for Map.
! * @param owner
! */
! public Map(PersistentClass owner) {
! super(owner);
}
!
public PersistentCollectionType getType() {
! return isSorted() ? TypeFactory.sortedMap( getRole(), getComparator() ): TypeFactory.map( getRole() );
}
public Class wrapperClass() {
! return isSorted() ? net.sf.hibernate.collection.SortedMap.class : net.sf.hibernate.collection.Map.class;
}
Index: OneToMany.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/OneToMany.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** OneToMany.java 19 Jan 2003 11:47:07 -0000 1.4
--- OneToMany.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 2,11 ****
package net.sf.hibernate.mapping;
- import net.sf.hibernate.Hibernate;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.type.EntityType;
- import net.sf.hibernate.util.ReflectHelper;
-
- import org.w3c.dom.Node;
public class OneToMany {
--- 2,7 ----
***************
*** 13,18 ****
//TODO: actually keep a list of columns
! private final EntityType type;
! private final Table referencingTable;
public EntityType getType() {
--- 9,14 ----
//TODO: actually keep a list of columns
! private EntityType type;
! private Table referencingTable;
public EntityType getType() {
***************
*** 20,33 ****
}
! public OneToMany(Node node, PersistentClass owner) throws MappingException {
this.referencingTable = (owner==null) ? null : owner.getTable();
- try {
- type = (EntityType) Hibernate.association( ReflectHelper.classForName(
- node.getAttributes().getNamedItem("class").getNodeValue()
- ) );
- }
- catch (ClassNotFoundException cnfe) {
- throw new MappingException("Associated class not found", cnfe);
- }
}
--- 16,21 ----
}
! public OneToMany(PersistentClass owner) throws MappingException {
this.referencingTable = (owner==null) ? null : owner.getTable();
}
***************
*** 35,38 ****
--- 23,35 ----
return referencingTable;
}
+
+ /**
+ * Sets the type.
+ * @param type The type to set
+ */
+ public void setType(EntityType type) {
+ this.type = type;
+ }
+
}
Index: OneToOne.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/OneToOne.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** OneToOne.java 5 Jan 2003 02:11:22 -0000 1.4
--- OneToOne.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 5,11 ****
import java.util.Iterator;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
-
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
--- 5,8 ----
***************
*** 13,17 ****
import net.sf.hibernate.type.AssociationType;
import net.sf.hibernate.type.EntityType;
- import net.sf.hibernate.type.Type;
import net.sf.hibernate.type.TypeFactory;
--- 10,13 ----
***************
*** 22,49 ****
private Value identifier;
! // 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();
- Node constrNode = atts.getNamedItem("constrained");
- constrained = constrNode!=null && constrNode.getNodeValue().equals("true");
-
- foreignKeyType = constrained ? AssociationType.FOREIGN_KEY_FROM_PARENT : AssociationType.FOREIGN_KEY_TO_PARENT;
-
- Node typeNode = atts.getNamedItem("class");
- if (typeNode==null) return null;
- try {
- return TypeFactory.oneToOne( ReflectHelper.classForName( typeNode.getNodeValue() ), foreignKeyType );
- }
- catch (Exception e) {
- throw new MappingException("Could not find class: " + typeNode.getNodeValue());
- }
- }
-
public void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException {
try {
--- 18,26 ----
private Value identifier;
! public OneToOne(Table table, Value identifier) throws MappingException {
! super(table);
this.identifier = identifier;
}
public void setTypeByReflection(Class propertyClass, String propertyName) throws MappingException {
try {
***************
*** 56,61 ****
}
}
! public void createForeignKeys(Root root, Table table) {
! if (constrained) createForeignKeyOfClass( root, table, ( (EntityType) getType() ).getPersistentClass() );
}
--- 33,38 ----
}
}
! public void createForeignKey() {
! if (constrained) createForeignKeyOfClass( ( (EntityType) getType() ).getPersistentClass() );
}
***************
*** 66,69 ****
--- 43,95 ----
return list;
}
+ /**
+ * Returns the constrained.
+ * @return boolean
+ */
+ public boolean isConstrained() {
+ return constrained;
+ }
+
+ /**
+ * Returns the foreignKeyType.
+ * @return AssociationType.ForeignKeyType
+ */
+ public AssociationType.ForeignKeyType getForeignKeyType() {
+ return foreignKeyType;
+ }
+
+ /**
+ * Returns the identifier.
+ * @return Value
+ */
+ public Value getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * Sets the constrained.
+ * @param constrained The constrained to set
+ */
+ public void setConstrained(boolean constrained) {
+ this.constrained = constrained;
+ }
+
+ /**
+ * Sets the foreignKeyType.
+ * @param foreignKeyType The foreignKeyType to set
+ */
+ public void setForeignKeyType(
+ AssociationType.ForeignKeyType foreignKeyType) {
+ this.foreignKeyType = foreignKeyType;
+ }
+
+ /**
+ * Sets the identifier.
+ * @param identifier The identifier to set
+ */
+ public void setIdentifier(Value identifier) {
+ this.identifier = identifier;
+ }
+
}
Index: PersistentClass.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/PersistentClass.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PersistentClass.java 25 Jan 2003 00:13:55 -0000 1.7
--- PersistentClass.java 27 Jan 2003 07:12:03 -0000 1.8
***************
*** 5,57 ****
import java.util.Iterator;
- import net.sf.hibernate.MappingException;
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.util.JoinedIterator;
- import net.sf.hibernate.util.ReflectHelper;
- import net.sf.hibernate.util.StringHelper;
-
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
public abstract class PersistentClass {
! private final Class persistentClass;
! private final String className;
! private final String discriminatorValue;
! private final ArrayList properties = new ArrayList();
private Table table;
private final ArrayList subclasses = new ArrayList();
private final ArrayList subclassProperties = new ArrayList();
private final ArrayList subclassTables = new ArrayList();
- private Class proxyInterface; //can be final
- private final boolean dynamicUpdate;
-
- protected PersistentClass(Node node) throws MappingException {
- NamedNodeMap atts = node.getAttributes();
- className = atts.getNamedItem("name").getNodeValue();
- //CLASS
- try {
- persistentClass = ReflectHelper.classForName(className);
- }
- catch ( ClassNotFoundException cnfe ) {
- throw new MappingException( "persistent class not found", cnfe );
- }
- //PROXY INTERFACE
- Node proxyNode = atts.getNamedItem("proxy");
- if (proxyNode!=null) {
- try {
- proxyInterface = ReflectHelper.classForName( proxyNode.getNodeValue() );
- }
- catch (ClassNotFoundException cnfe) {
- throw new MappingException(cnfe);
- }
- }
- //DISCRIMINATOR
- Node discriminatorNode = atts.getNamedItem("discriminator-value");
- discriminatorValue = (discriminatorNode==null) ? className : discriminatorNode.getNodeValue();
- //DYNAMIC UPDATE
- Node dynamicNode = atts.getNamedItem("dynamic-update");
- dynamicUpdate = (dynamicNode==null) ? false : "true".equals( dynamicNode.getNodeValue() );
- }
public boolean useDynamicUpdate() {
--- 5,22 ----
import java.util.Iterator;
import net.sf.hibernate.cache.CacheConcurrencyStrategy;
import net.sf.hibernate.util.JoinedIterator;
public abstract class PersistentClass {
!
! private Class persistentClass;
! private String discriminatorValue;
! private ArrayList properties = new ArrayList();
private Table table;
+ private Class proxyInterface;
+ private boolean dynamicUpdate;
private final ArrayList subclasses = new ArrayList();
private final ArrayList subclassProperties = new ArrayList();
private final ArrayList subclassTables = new ArrayList();
public boolean useDynamicUpdate() {
***************
*** 63,115 ****
}
! protected void addSubclass(Subclass subclass) {
subclasses.add(subclass);
}
- protected void propertiesFromXML(Node node, Root root) throws MappingException {
-
- NodeList list = node.getChildNodes();
- String path = StringHelper.unqualify(className);
- Table table = getTable();
- for ( int i=0; i<list.getLength(); i++ ) {
-
- Node subnode = list.item(i);
- String name = subnode.getNodeName();
- String propertyName = Property.getPropertyName(subnode);
-
- Root.CollectionType collectType = Root.CollectionType.collectionTypeFromString(name);
- Value value = null;
- if (collectType!=null) {
- 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) ) {
- value = new ManyToOne(subnode, path, propertyName, true, table, root);
- }
- else if ( "one-to-one".equals(name) ) {
- value = new OneToOne(subnode, getIdentifier(), path, true, table, root);
- }
- else if ( "property".equals(name) ) {
- value = new Value(subnode, true, table, root, propertyName);
- }
- else if ( "component".equals(name) || "dynabean".equals(name) ) {
- Class reflectedClass = ReflectHelper.getGetter( getPersistentClass(), propertyName ).getReturnType();
- value = new Component(subnode, reflectedClass, path, this, true, table, root);
- }
- else if ( "subclass".equals(name) || "joined-subclass".equals(name) ) {
- Subclass subclass = new Subclass( this, list.item(i), getTable(), root );
- addSubclass(subclass);
- root.addPersistentClass(subclass);
- }
- if ( value!=null) {
- value.setTypeByReflection(persistentClass, propertyName);
- value.createForeignKeys(root, table);
- addProperty( new Property(subnode, value, root) );
- }
- }
- }
-
public boolean hasSubclasses() {
return subclasses.size() > 0;
--- 28,35 ----
}
! public void addSubclass(Subclass subclass) {
subclasses.add(subclass);
}
public boolean hasSubclasses() {
return subclasses.size() > 0;
***************
*** 201,204 ****
--- 121,157 ----
public abstract RootClass getRootClass();
public abstract Value getKey();
+
+ /**
+ * Sets the discriminatorValue.
+ * @param discriminatorValue The discriminatorValue to set
+ */
+ public void setDiscriminatorValue(String discriminatorValue) {
+ this.discriminatorValue = discriminatorValue;
+ }
+
+ /**
+ * Sets the dynamicUpdate.
+ * @param dynamicUpdate The dynamicUpdate to set
+ */
+ public void setDynamicUpdate(boolean dynamicUpdate) {
+ this.dynamicUpdate = dynamicUpdate;
+ }
+
+ /**
+ * Sets the persistentClass.
+ * @param persistentClass The persistentClass to set
+ */
+ public void setPersistentClass(Class persistentClass) {
+ this.persistentClass = persistentClass;
+ }
+
+ /**
+ * Sets the proxyInterface.
+ * @param proxyInterface The proxyInterface to set
+ */
+ public void setProxyInterface(Class proxyInterface) {
+ this.proxyInterface = proxyInterface;
+ }
+
}
Index: PrimitiveArray.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/PrimitiveArray.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PrimitiveArray.java 19 Jan 2003 11:47:07 -0000 1.4
--- PrimitiveArray.java 27 Jan 2003 07:12:03 -0000 1.5
***************
*** 2,14 ****
package net.sf.hibernate.mapping;
- import net.sf.hibernate.MappingException;
-
- import org.w3c.dom.Node;
-
public class PrimitiveArray extends Array {
! public PrimitiveArray(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! super(node, prefix, owner, root);
}
!
public boolean isPrimitiveArray() {
return true;
--- 2,15 ----
package net.sf.hibernate.mapping;
public class PrimitiveArray extends Array {
!
! /**
! * Constructor for PrimitiveArray.
! * @param owner
! */
! public PrimitiveArray(PersistentClass owner) {
! super(owner);
}
!
public boolean isPrimitiveArray() {
return true;
Index: Property.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Property.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Property.java 24 Jan 2003 16:15:57 -0000 1.5
--- Property.java 27 Jan 2003 07:12:03 -0000 1.6
***************
*** 14,19 ****
public class Property {
! private final String name;
! private final Value value;
private String cascade;
private boolean mutable;
--- 14,19 ----
public class Property {
! private String name;
! private Value value;
private String cascade;
private boolean mutable;
***************
*** 39,56 ****
}
- public Property(Node node, Value value, Root root) throws MappingException {
- name = getPropertyName(node);
- this.value=value;
- Type type = value.getType();
- if (type==null) throw new MappingException( "Could not determine a property type for: " + name );
- Node cascadeNode = node.getAttributes().getNamedItem("cascade");
- cascade = (cascadeNode==null) ? root.getDefaultCascade() : cascadeNode.getNodeValue();
- Node mutableNode = node.getAttributes().getNamedItem("mutable");
- mutable = (mutableNode==null) ? true : "true".equals( mutableNode.getNodeValue() );
- }
-
public Value getValue() {
return value;
}
public static String getPropertyName(Node node) {
NamedNodeMap atts = node.getAttributes();
--- 39,46 ----
}
public Value getValue() {
return value;
}
+
public static String getPropertyName(Node node) {
NamedNodeMap atts = node.getAttributes();
***************
*** 61,65 ****
}
! public Cascades.CascadeStyle cascade() throws MappingException {
if ( value.getType().isComponentType() ) {
AbstractComponentType actype = (AbstractComponentType) value.getType();
--- 51,55 ----
}
! public Cascades.CascadeStyle getCascadeStyle() throws MappingException {
if ( value.getType().isComponentType() ) {
AbstractComponentType actype = (AbstractComponentType) value.getType();
***************
*** 90,93 ****
--- 80,123 ----
+ /**
+ * Returns the cascade.
+ * @return String
+ */
+ public String getCascade() {
+ return cascade;
+ }
+
+ /**
+ * Sets the cascade.
+ * @param cascade The cascade to set
+ */
+ public void setCascade(String cascade) {
+ this.cascade = cascade;
+ }
+
+ /**
+ * Sets the mutable.
+ * @param mutable The mutable to set
+ */
+ public void setMutable(boolean mutable) {
+ this.mutable = mutable;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the value.
+ * @param value The value to set
+ */
+ public void setValue(Value value) {
+ this.value = value;
+ }
+
}
Index: Root.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Root.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Root.java 20 Jan 2003 12:48:13 -0000 1.6
--- Root.java 27 Jan 2003 07:12:03 -0000 1.7
***************
*** 2,12 ****
package net.sf.hibernate.mapping;
! import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
- import org.w3c.dom.Document;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
import net.sf.hibernate.MappingException;
--- 2,9 ----
package net.sf.hibernate.mapping;
! import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.hibernate.MappingException;
***************
*** 17,135 ****
import net.sf.hibernate.cache.ReadOnlyCache;
import net.sf.hibernate.cache.ReadWriteCache;
- import net.sf.hibernate.type.Type;
import net.sf.hibernate.util.StringHelper;
public class Root {
! static final String ROOT_ROLE_NAME = StringHelper.EMPTY_STRING;
! static final char ROLE_SEPERATOR = '/';
!
! Log log = LogFactory.getLog(Root.class);
!
! private final java.util.Map classes;
! private final java.util.Map collections;
! private final java.util.Map tables;
! private final java.util.Map queries;
! private final String schemaName;
! private final String defaultCascade;
! private static final String[] NO_STRINGS = {};
! private static final Type[] NO_TYPES = {};
! private static final Integer[] NO_INTEGERS = {};
! //This inner class implements a case statement....perhaps im being a bit over-clever here
! public static abstract class CollectionType {
! private String xmlTag;
! public abstract Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException;
! CollectionType(String xmlTag) {
! this.xmlTag = xmlTag;
! }
! public String toString() {
! return xmlTag;
! }
! private static final CollectionType MAP = new CollectionType("map") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! return new Map(node, prefix, owner, root);
! }
! };
! private static final CollectionType SET = new CollectionType("set") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! return new Set(node, prefix, owner, root);
! }
! };
! private static final CollectionType LIST = new CollectionType("list") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! return new List(node, prefix, owner, root);
! }
! };
! private static final CollectionType BAG = new CollectionType("bag") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! return new Bag(node, prefix, owner, root);
! }
! };
! private static final CollectionType ARRAY = new CollectionType("array") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! return new Array(node, prefix, owner, root);
! }
! };
! private static final CollectionType PRIMITIVE_ARRAY = new CollectionType("primitive-array") {
! public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
! return new PrimitiveArray(node, prefix, owner, root);
! }
! };
! private static final HashMap INSTANCES = new HashMap();
! static {
! INSTANCES.put(MAP.toString(), MAP);
! INSTANCES.put(BAG.toString(), BAG);
! INSTANCES.put(SET.toString(), SET);
! INSTANCES.put(LIST.toString(), LIST);
! INSTANCES.put(ARRAY.toString(), ARRAY);
! INSTANCES.put(PRIMITIVE_ARRAY.toString(), PRIMITIVE_ARRAY);
! }
! public static CollectionType collectionTypeFromString(String xmlTagName) {
! return (CollectionType) INSTANCES.get(xmlTagName);
! }
! }
! public Root(
! Document doc,
! java.util.Map classes,
! java.util.Map collections,
! java.util.Map tables,
! java.util.Map queries
! ) throws Exception {
!
this.classes = classes;
this.collections = collections;
this.queries = queries;
this.tables = tables;
-
- // Create maps for all the collections and classes
-
- Node hmNode = doc.getElementsByTagName("hibernate-mapping").item(0);
- Node schemaNode = hmNode.getAttributes().getNamedItem("schema");
- schemaName = (schemaNode==null) ? null : schemaNode.getNodeValue();
- Node dcNode = hmNode.getAttributes().getNamedItem("default-cascade");
- defaultCascade = (dcNode==null) ? "none" : dcNode.getNodeValue();
-
- NodeList nodes = hmNode.getChildNodes();
- for ( int i=0; i<nodes.getLength(); i++ ) {
-
- Node n = nodes.item(i);
- String name = n.getNodeName();
- if ( name.equals("class") ) {
- RootClass rootclass = new RootClass( n, this );
- log.debug("Root class: " + rootclass.getName() + " -> " + rootclass.getTable().getName() );
- addPersistentClass(rootclass);
- }
- else if ( name.equals("query") ) {
- String qname = n.getAttributes().getNamedItem("name").getNodeValue();
- String query = n.getFirstChild().getNodeValue();
- log.debug("Named query: " + qname + " -> " + query);
- Object old = queries.put(qname, query);
- if (old!=null) throw new MappingException("duplicate query name: " + qname);
- }
-
- }
}
--- 14,38 ----
import net.sf.hibernate.cache.ReadOnlyCache;
import net.sf.hibernate.cache.ReadWriteCache;
import net.sf.hibernate.util.StringHelper;
public class Root {
! public static final String ROOT_ROLE_NAME = StringHelper.EMPTY_STRING;
! public static final char ROLE_SEPERATOR = '/';
! private static final Log log = LogFactory.getLog(Root.class);
! private final Map classes;
! private final Map collections;
! private final Map tables;
! private final Map queries;
! private String schemaName;
! private String defaultCascade;
! public Root(Map classes, Map collections, Map tables, Map queries) {
this.classes = classes;
this.collections = collections;
this.queries = queries;
this.tables = tables;
}
***************
*** 142,151 ****
if ( old!=null ) throw new MappingException( "duplicate collection role: " + collection.getRole() );
}
...
[truncated message content] |
|
From: <one...@us...> - 2003-01-27 07:12:08
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test
In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/test
Modified Files:
Contained.java Container.hbm.xml Immutable.hbm.xml
Log Message:
massive refactoring of XML mapping parsing code
Index: Contained.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Contained.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Contained.java 5 Jan 2003 02:11:23 -0000 1.3
--- Contained.java 27 Jan 2003 07:12:04 -0000 1.4
***************
*** 12,16 ****
public boolean equals(Object other) {
! return id==( (Contained) other ).id;
}
public int hashCode() {
--- 12,16 ----
public boolean equals(Object other) {
! return id==( (Contained) other ).getId();
}
public int hashCode() {
Index: Container.hbm.xml
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Container.hbm.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Container.hbm.xml 1 Jan 2003 13:56:48 -0000 1.1.1.1
--- Container.hbm.xml 27 Jan 2003 07:12:04 -0000 1.2
***************
*** 65,69 ****
<class name="net.sf.hibernate.test.Contained" proxy="net.sf.hibernate.test.Contained">
! <id name="id" column="container_id">
<generator class="native" />
</id>
--- 65,69 ----
<class name="net.sf.hibernate.test.Contained" proxy="net.sf.hibernate.test.Contained">
! <id name="id" column="container_id" unsaved-value="0">
<generator class="native" />
</id>
Index: Immutable.hbm.xml
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Immutable.hbm.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Immutable.hbm.xml 1 Jan 2003 13:57:07 -0000 1.1.1.1
--- Immutable.hbm.xml 27 Jan 2003 07:12:04 -0000 1.2
***************
*** 4,7 ****
--- 4,8 ----
<class name="net.sf.hibernate.test.Immutable" table="immut" mutable="false">
+ <jcs-cache usage="read-only"/>
<id name="id" column="id_" length="64">
<generator class="uuid.hex"/>
***************
*** 9,13 ****
<property name="foo"/>
<property name="bar"/>
- <cache timeout="1000000" type="readonly"/>
</class>
--- 10,13 ----
|
|
From: <one...@us...> - 2003-01-27 07:12:08
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/persister Modified Files: AbstractEntityPersister.java EntityPersister.java NormalizedEntityPersister.java Log Message: massive refactoring of XML mapping parsing code Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AbstractEntityPersister.java 26 Jan 2003 01:33:36 -0000 1.9 --- AbstractEntityPersister.java 27 Jan 2003 07:12:03 -0000 1.10 *************** *** 623,627 **** propertyMutability[i] = prop.isMutable(); ! cascadeStyles[i] = prop.cascade(); if ( cascadeStyles[i]!=Cascades.STYLE_NONE ) foundCascade = true; --- 623,627 ---- propertyMutability[i] = prop.isMutable(); ! cascadeStyles[i] = prop.getCascadeStyle(); if ( cascadeStyles[i]!=Cascades.STYLE_NONE ) foundCascade = true; Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/EntityPersister.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** EntityPersister.java 25 Jan 2003 01:26:07 -0000 1.12 --- EntityPersister.java 27 Jan 2003 07:12:03 -0000 1.13 *************** *** 709,713 **** propColumns.add(cols); joinedFetchesList.add( new Integer( ! prop.getValue().enableJoinedFetch() ) ); } --- 709,713 ---- propColumns.add(cols); joinedFetchesList.add( new Integer( ! prop.getValue().getOuterJoinFetchSetting() ) ); } Index: NormalizedEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/NormalizedEntityPersister.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NormalizedEntityPersister.java 25 Jan 2003 01:26:07 -0000 1.4 --- NormalizedEntityPersister.java 27 Jan 2003 07:12:03 -0000 1.5 *************** *** 807,811 **** propColumns.add(cols); joinedFetchesList.add( new Integer( ! prop.getValue().enableJoinedFetch() ) ); } --- 807,811 ---- propColumns.add(cols); joinedFetchesList.add( new Integer( ! prop.getValue().getOuterJoinFetchSetting() ) ); } |
|
From: <one...@us...> - 2003-01-27 07:12:08
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type
In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/type
Modified Files:
OneToOneType.java
Log Message:
massive refactoring of XML mapping parsing code
Index: OneToOneType.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/OneToOneType.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** OneToOneType.java 5 Jan 2003 02:11:24 -0000 1.3
--- OneToOneType.java 27 Jan 2003 07:12:04 -0000 1.4
***************
*** 57,86 ****
String[] names,
SessionImplementor session,
! Object owner)
! throws HibernateException, SQLException {
! return session.getEntityIdentifier(owner);
! }
! public Object resolveIdentifier(Object value, SessionImplementor session) throws HibernateException, SQLException {
!
! if (value==null) return null;
!
! Class clazz = getPersistentClass();
! Serializable id = (Serializable) value;
!
! return isNullable() ?
! session.internalLoadOneToOne(clazz, id) :
! session.internalLoad(clazz, id);
! }
! public boolean isNullable() {
! return foreignKeyType==AssociationType.FOREIGN_KEY_TO_PARENT;
! }
}
!
!
!
--- 57,82 ----
String[] names,
SessionImplementor session,
! Object owner
! ) throws HibernateException, SQLException {
! return session.getEntityIdentifier(owner);
! }
!
! public Object resolveIdentifier(Object value, SessionImplementor session) throws HibernateException, SQLException {
! if (value==null) return null;
! Class clazz = getPersistentClass();
! Serializable id = (Serializable) value;
+ return isNullable() ?
+ session.internalLoadOneToOne(clazz, id) :
+ session.internalLoad(clazz, id);
}
+ public boolean isNullable() {
+ return foreignKeyType==AssociationType.FOREIGN_KEY_TO_PARENT;
+ }
! }
!
|
|
From: <one...@us...> - 2003-01-27 07:12:08
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/util Modified Files: XMLHelper.java Log Message: massive refactoring of XML mapping parsing code Index: XMLHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/XMLHelper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLHelper.java 5 Jan 2003 02:11:25 -0000 1.3 --- XMLHelper.java 27 Jan 2003 07:12:04 -0000 1.4 *************** *** 2,13 **** package net.sf.hibernate.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; ! import javax.xml.parsers.*; ! ! ! import org.xml.sax.*; ! import java.io.*; public final class XMLHelper { --- 2,20 ---- package net.sf.hibernate.util; + import java.io.ByteArrayInputStream; + import java.io.IOException; + + import javax.xml.parsers.DocumentBuilder; + import javax.xml.parsers.DocumentBuilderFactory; + import javax.xml.parsers.ParserConfigurationException; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; ! import org.xml.sax.EntityResolver; ! import org.xml.sax.ErrorHandler; ! import org.xml.sax.InputSource; ! import org.xml.sax.SAXException; ! import org.xml.sax.SAXParseException; public final class XMLHelper { |
|
From: <one...@us...> - 2003-01-27 07:12:06
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/collection Modified Files: CollectionPersister.java Log Message: massive refactoring of XML mapping parsing code Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/CollectionPersister.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CollectionPersister.java 26 Jan 2003 01:33:34 -0000 1.6 --- CollectionPersister.java 27 Jan 2003 07:12:03 -0000 1.7 *************** *** 143,147 **** span = collection.getElement().getColumnSpan(); elementColumnNames = new String[span]; ! enableJoinedFetch = collection.getElement().enableJoinedFetch(); iter = collection.getElement().getColumnIterator(); --- 143,147 ---- span = collection.getElement().getColumnSpan(); elementColumnNames = new String[span]; ! enableJoinedFetch = collection.getElement().getOuterJoinFetchSetting(); iter = collection.getElement().getColumnIterator(); |
|
From: <one...@us...> - 2003-01-27 07:12:06
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/cfg
Modified Files:
Configuration.java
Added Files:
Binder.java
Log Message:
massive refactoring of XML mapping parsing code
--- NEW FILE: Binder.java ---
//$Id: Binder.java,v 1.1 2003/01/27 07:12:03 oneovthafew Exp $
package net.sf.hibernate.cfg;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.engine.Cascades;
import net.sf.hibernate.loader.OuterJoinLoader;
import net.sf.hibernate.mapping.Array;
import net.sf.hibernate.mapping.Association;
import net.sf.hibernate.mapping.Bag;
import net.sf.hibernate.mapping.Collection;
import net.sf.hibernate.mapping.Column;
import net.sf.hibernate.mapping.Component;
import net.sf.hibernate.mapping.ForeignKey;
[...988 lines suppressed...]
public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
PrimitiveArray array = new PrimitiveArray(owner);
Binder.bindArray(node, array, prefix, root);
return array;
}
};
private static final HashMap INSTANCES = new HashMap();
static {
INSTANCES.put(MAP.toString(), MAP);
INSTANCES.put(BAG.toString(), BAG);
INSTANCES.put(SET.toString(), SET);
INSTANCES.put(LIST.toString(), LIST);
INSTANCES.put(ARRAY.toString(), ARRAY);
INSTANCES.put(PRIMITIVE_ARRAY.toString(), PRIMITIVE_ARRAY);
}
public static CollectionType collectionTypeFromString(String xmlTagName) {
return (CollectionType) INSTANCES.get(xmlTagName);
}
}
}
Index: Configuration.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Configuration.java 26 Jan 2003 03:16:32 -0000 1.6
--- Configuration.java 27 Jan 2003 07:12:03 -0000 1.7
***************
*** 6,10 ****
import java.util.ArrayList;
import java.util.HashMap;
- import java.util.Map;
import java.util.Properties;
import java.util.jar.JarFile;
--- 6,9 ----
***************
*** 35,43 ****
import net.sf.hibernate.id.PersistentIdentifierGenerator;
import net.sf.hibernate.impl.SessionFactoryImpl;
! import net.sf.hibernate.mapping.Collection;
import net.sf.hibernate.mapping.ForeignKey;
import net.sf.hibernate.mapping.Index;
import net.sf.hibernate.mapping.PersistentClass;
import net.sf.hibernate.mapping.Root;
import net.sf.hibernate.mapping.Table;
import net.sf.hibernate.dialect.Dialect;
--- 34,47 ----
import net.sf.hibernate.id.PersistentIdentifierGenerator;
import net.sf.hibernate.impl.SessionFactoryImpl;
! import net.sf.hibernate.mapping.Array;
! import net.sf.hibernate.mapping.Bag;
import net.sf.hibernate.mapping.ForeignKey;
import net.sf.hibernate.mapping.Index;
+ import net.sf.hibernate.mapping.List;
+ import net.sf.hibernate.mapping.Map;
import net.sf.hibernate.mapping.PersistentClass;
+ import net.sf.hibernate.mapping.PrimitiveArray;
import net.sf.hibernate.mapping.Root;
+ import net.sf.hibernate.mapping.Set;
import net.sf.hibernate.mapping.Table;
import net.sf.hibernate.dialect.Dialect;
***************
*** 156,160 ****
private void add(Document doc) throws Exception {
try {
! new Root(doc, classes, collections, tables, namedQueries);
}
catch (MappingException me) {
--- 160,164 ----
private void add(Document doc) throws Exception {
try {
! Binder.bindRoot( doc, createRoot() );
}
catch (MappingException me) {
***************
*** 164,167 ****
--- 168,175 ----
}
+ public Root createRoot() {
+ return new Root(classes, collections, tables, namedQueries);
+ }
+
/**
* Read mappings from an <tt>InputStream</tt>
***************
*** 407,411 ****
Iterator iter = collections.values().iterator();
while ( iter.hasNext() ) {
! ( (Collection) iter.next() ).secondPassCompile(classes);
}
--- 415,425 ----
Iterator iter = collections.values().iterator();
while ( iter.hasNext() ) {
! Object coll = iter.next();
! if (coll instanceof Set) Binder.bindSetSecondPass( (Set) coll, classes );
! if (coll instanceof Map) Binder.bindMapSecondPass( (Map) coll, classes );
! if (coll instanceof List) Binder.bindListSecondPass( (List) coll, classes );
! if (coll instanceof Bag) Binder.bindCollectionSecondPass( (Bag) coll, classes );
! if (coll instanceof Array) Binder.bindListSecondPass( (Array) coll, classes );
! if (coll instanceof PrimitiveArray) Binder.bindListSecondPass( (PrimitiveArray) coll, classes );
}
***************
*** 434,438 ****
* Get the named queries
*/
! public Map getNamedQueries() {
return namedQueries;
}
--- 448,452 ----
* Get the named queries
*/
! public java.util.Map getNamedQueries() {
return namedQueries;
}
|
|
From: <one...@us...> - 2003-01-27 07:12:05
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate
In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate
Modified Files:
hibernate-mapping.dtd
Log Message:
massive refactoring of XML mapping parsing code
Index: hibernate-mapping.dtd
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hibernate-mapping.dtd,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** hibernate-mapping.dtd 9 Jan 2003 12:24:50 -0000 1.2
--- hibernate-mapping.dtd 27 Jan 2003 07:12:03 -0000 1.3
***************
*** 339,349 ****
<!ATTLIST jcs-cache usage CDATA #REQUIRED> <!-- read-only | read-write -->
- <!-- The cache element enables caching of an entity class.
- semi-deprecated - use a jcs-cache. -->
- <!ELEMENT cache EMPTY>
- <!ATTLIST cache timeout CDATA #IMPLIED> <!-- default: never expire -->
- <!ATTLIST cache impl-class CDATA #IMPLIED> <!-- default: hashbelt -->
- <!ATTLIST cache type CDATA #REQUIRED> <!-- readonly | readwrite -->
-
<!-- The query element declares a named Hibernate query string -->
--- 339,342 ----
|
|
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();
|
|
From: <one...@us...> - 2003-01-26 03:41:30
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/map
In directory sc8-pr-cvs1:/tmp/cvs-serv15674/hibernate/map
Modified Files:
OneToMany.java
Log Message:
minor changes
Index: OneToMany.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/OneToMany.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** OneToMany.java 26 Nov 2002 03:35:43 -0000 1.13
--- OneToMany.java 26 Jan 2003 03:41:27 -0000 1.14
***************
*** 1,9 ****
//$Id$
package cirrus.hibernate.map;
!
import org.w3c.dom.*;
! import cirrus.hibernate.helpers.ReflectHelper;
! import cirrus.hibernate.type.EntityType;
import cirrus.hibernate.Hibernate;
import cirrus.hibernate.MappingException;
public class OneToMany {
--- 1,10 ----
//$Id$
package cirrus.hibernate.map;
!
import org.w3c.dom.Node;
!
import cirrus.hibernate.Hibernate;
import cirrus.hibernate.MappingException;
+ import cirrus.hibernate.helpers.ReflectHelper;
+ import cirrus.hibernate.type.EntityType;
public class OneToMany {
***************
*** 22,26 ****
try {
type = (EntityType) Hibernate.association( ReflectHelper.classForName(
! node.getAttributes().getNamedItem("class").getNodeValue()
) );
}
--- 23,27 ----
try {
type = (EntityType) Hibernate.association( ReflectHelper.classForName(
! node.getAttributes().getNamedItem("class").getNodeValue()
) );
}
|
|
From: <one...@us...> - 2003-01-26 03:17:48
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src
In directory sc8-pr-cvs1:/tmp/cvs-serv9441/reference/src
Modified Files:
session_configuration.xml transactions.xml
Log Message:
new Configuration API
Index: session_configuration.xml
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/session_configuration.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** session_configuration.xml 1 Jan 2003 13:46:38 -0000 1.1.1.1
--- session_configuration.xml 26 Jan 2003 03:17:45 -0000 1.2
***************
*** 4,22 ****
<sect1 id="session-configuration-s1">
! <title>Programmatic Datastore Configuration</title>
<para>
! An instance of <literal>net.sf.hibernate.Datastore</literal>
represents an entire set of mappings of an application's Java types to a
relational database. These mappings are compiled from various XML mapping
! files. You may obtain a <literal>Datastore</literal> instance by
! calling <literal>Hibernate.createDatastore()</literal>. Heres an
! example of setting up a datastore from mappings defined in two XML
! configuration files:
</para>
! <programlisting><![CDATA[Datastore ds = Hibernate.createDatastore()
! .storeFile("vertex.hbm.xml")
! .storeFile("edge.hbm.xml");]]></programlisting>
<para>
--- 4,21 ----
<sect1 id="session-configuration-s1">
! <title>Programmatic Configuration</title>
<para>
! An instance of <literal>net.sf.hibernate.Configuration</literal>
represents an entire set of mappings of an application's Java types to a
relational database. These mappings are compiled from various XML mapping
! files. You may obtain a <literal>Configuration</literal> instance by
! instantiating it directly. Heres an example of setting up a datastore from
! mappings defined in two XML configuration files:
</para>
! <programlisting><![CDATA[Configuration cfg = new Configuration()
! .addFile("vertex.hbm.xml")
! .addFile("edge.hbm.xml");]]></programlisting>
<para>
***************
*** 25,31 ****
</para>
! <programlisting><![CDATA[Datastore ds = Hibernate.createDatastore()
! .storeClass(eg.Vertex.class)
! .storeClass(eg.Edge.class);]]></programlisting>
<para>
--- 24,30 ----
</para>
! <programlisting><![CDATA[Configuration cfg = new Configuration()
! .addClass(eg.Vertex.class)
! .addClass(eg.Edge.class);]]></programlisting>
<para>
***************
*** 36,40 ****
<para>
! A <literal>Datastore</literal> is intended as a configuration-time object, to be
discarded once a <literal>SessionFactory</literal> is built.
</para>
--- 35,50 ----
<para>
! A <literal>Configuration</literal> also specifies various optional properties.
! </para>
!
! <programlisting><![CDATA[Properties props = new Properties();
! ...
! Configuration cfg = new Configuration()
! .addClass(eg.Vertex.class)
! .addClass(eg.Edge.class)
! .setProperties(props);]]></programlisting>
!
! <para>
! A <literal>Configuration</literal> is intended as a configuration-time object, to be
discarded once a <literal>SessionFactory</literal> is built.
</para>
***************
*** 44,49 ****
<title>Obtaining a SessionFactory</title>
<para>
! When all mappings have been compiled by the <literal>Datastore</literal>, the application
! must obtain an factory for <literal>Session</literal> instances. This factory is intended
to be shared by all application threads. However, Hibernate does allow your application to
instantiate more than one <literal>SessionFactory</literal>. This is useful if you are
--- 54,59 ----
<title>Obtaining a SessionFactory</title>
<para>
! When all mappings have been parsed by the <literal>Configuration</literal>, the application
! must obtain a factory for <literal>Session</literal> instances. This factory is intended
to be shared by all application threads. However, Hibernate does allow your application to
instantiate more than one <literal>SessionFactory</literal>. This is useful if you are
***************
*** 51,61 ****
</para>
! <programlisting><![CDATA[//configure the SessionFactory using System properties
! SessionFactory sessions = ds.buildSessionFactory();]]></programlisting>
- <programlisting><![CDATA[//configure the SessionFactory using a given instance of java.util.Properties
- Properties props = new Properties();
- ...
- SessionFactory sessions = ds.buildSessionFactory(props);]]></programlisting>
</sect1>
--- 61,66 ----
</para>
! <programlisting><![CDATA[SessionFactory sessions = cfg.buildSessionFactory();]]></programlisting>
</sect1>
***************
*** 65,73 ****
<para>
A <literal>SessionFactory</literal> may open a <literal>Session</literal> on
! a user-provided JDBC connection. This
! design choice frees the application to obtain JDBC connections wherever it
! pleases - from an application server connection pool for example. The
! application must be careful not to open two concurrent sessions on the same
! connection.
</para>
--- 70,76 ----
<para>
A <literal>SessionFactory</literal> may open a <literal>Session</literal> on
! a user-provided JDBC connection. This design choice frees the application to
! obtain JDBC connections wherever it pleases. The application must be careful
! not to open two concurrent sessions on the same connection.
</para>
***************
*** 102,106 ****
<para>
Pass an instance of <literal>java.util.Properties</literal> to
! <literal>Datastore.buildSessionFactory()</literal>.
</para>
</listitem>
--- 105,109 ----
<para>
Pass an instance of <literal>java.util.Properties</literal> to
! <literal>Configuration.setProperties()</literal>.
</para>
</listitem>
***************
*** 126,132 ****
<para>
! Hibernate will obtain (and pool) connections using
! <literal>java.sql.DriverManager</literal> if you set the
! following properties:
</para>
--- 129,134 ----
<para>
! Hibernate will obtain (and pool) connections using <literal>java.sql.DriverManager</literal>
! if you set the following properties:
</para>
***************
*** 173,178 ****
<listitem>
<para>
! <literal>hibernate.connection.xxxx</literal> = <emphasis>pass the JDBC property <literal>xxxx</literal>
! to <literal>DriverManager.getConnection()</literal></emphasis>
</para>
</listitem>
--- 175,180 ----
<listitem>
<para>
! <literal>hibernate.connection.xxxx</literal> = <emphasis>pass the JDBC property
! <literal>xxxx</literal> to <literal>DriverManager.getConnection()</literal></emphasis>
</para>
</listitem>
***************
*** 262,266 ****
<para>
<literal>hibernate.jndi.class</literal> = <emphasis>class of the JNDI
! InitialContextFactory</emphasis> (optional)
</para>
</listitem>
--- 264,274 ----
<para>
<literal>hibernate.jndi.class</literal> = <emphasis>class of the JNDI
! <literal>InitialContextFactory</literal></emphasis> (optional)
! </para>
! </listitem>
! <listitem>
! <para>
! <literal>hibernate.jndi.xxxx</literal> = <emphasis>pass the property <literal>xxxx</literal>
! to the JNDI <literal>InitialContextFactory</literal></emphasis> (optional)
</para>
</listitem>
***************
*** 521,530 ****
<para>
! An alternative approach is to specify a <literal>Datastore</literal> configuration in a
! file called <literal>hibernate.cfg.xml</literal> and then call
! <literal>Hibernate.configure()</literal> as many times as you like during application
! initialization (the actual configuration will only be done once). The configuration file
! is required in the root of your |CLASSPATH|. Your application may then obtain a reference
! to a <literal>SessionFactory</literal> from JNDI. The configuration file format looks like:
</para>
--- 529,535 ----
<para>
! An alternative approach is to specify a full configuration in a file named
! <literal>hibernate.cfg.xml</literal>. The configuration file is expected to
! be in the root of your |CLASSPATH|.
</para>
***************
*** 536,545 ****
<hibernate-configuration>
- <!-- shared properties -->
- <property name="show_sql">false</property>
- <property name="use_outer_join">true</property>
- <property name="jta.UserTransaction">
- java:comp/UserTransaction/
- </property>
<!-- a SessionFactory instance listed as /jndi/name -->
--- 541,544 ----
***************
*** 549,552 ****
--- 548,556 ----
<property name="connection.datasource">my/first/datasource</property>
<property name="dialect">net.sf.hibernate.sql.MySQLDialect</property>
+ <property name="show_sql">false</property>
+ <property name="use_outer_join">true</property>
+ <property name="jta.UserTransaction">
+ java:comp/UserTransaction/
+ </property>
<!-- mapping files -->
***************
*** 556,566 ****
</session-factory>
- <session-factory name="/another/jndi/name">
- <property name="connection.datasource">my/other/datasource</property>
- <property name="dialect">net.sf.hibernate.sql.OracleDialect</property>
- <mapping file="C:/mapping/my_mappings.hbm.xml"/>
- </session-factory>
-
</hibernate-configuration>]]></programlisting>
</sect1>
--- 560,572 ----
</session-factory>
</hibernate-configuration>]]></programlisting>
+
+ <para>
+ Configuring Hibernate is then as simple as
+ </para>
+
+ <programlisting><![CDATA[SessionFactory sf = new Configuration()
+ .configure()
+ .buildSessionFactory();]]></programlisting>
</sect1>
Index: transactions.xml
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/transactions.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** transactions.xml 1 Jan 2003 13:46:39 -0000 1.1.1.1
--- transactions.xml 26 Jan 2003 03:17:45 -0000 1.2
***************
*** 13,17 ****
<sect1 id="transactions-s1">
! <title>Datastores, Sessions and Factories</title>
<para>
A <literal>SessionFactory</literal> is an expensive-to-create, threadsafe object
--- 13,17 ----
<sect1 id="transactions-s1">
! <title>Configurations, Sessions and Factories</title>
<para>
A <literal>SessionFactory</literal> is an expensive-to-create, threadsafe object
|
|
From: <one...@us...> - 2003-01-26 03:16:35
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv9127/sf/hibernate/type Modified Files: Type.java Log Message: fixed a problem with parsing cfg file Index: Type.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/Type.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Type.java 19 Jan 2003 11:47:08 -0000 1.4 --- Type.java 26 Jan 2003 03:16:32 -0000 1.5 *************** *** 56,60 **** * @see java.sql.Types * @param pi ! * @return int[] the typecodes * @throws MappingException */ --- 56,60 ---- * @see java.sql.Types * @param pi ! * @return the typecodes * @throws MappingException */ *************** *** 69,73 **** /** ! * The class returned by <tt>nullSafeGet()<tt> methods. This is used to establish * the class of an array of this type. * --- 69,73 ---- /** ! * The class returned by <tt>nullSafeGet()</tt> methods. This is used to establish * the class of an array of this type. * |
|
From: <one...@us...> - 2003-01-26 03:16:35
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv9127/sf/hibernate/cfg
Modified Files:
Configuration.java
Log Message:
fixed a problem with parsing cfg file
Index: Configuration.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Configuration.java 26 Jan 2003 02:37:02 -0000 1.5
--- Configuration.java 26 Jan 2003 03:16:32 -0000 1.6
***************
*** 616,620 ****
}
! Node sfNode = doc.getDocumentElement();
String name = sfNode.getAttributes().getNamedItem("name").getNodeValue();
properties.setProperty(Environment.SESSION_FACTORY_NAME, name);
--- 616,620 ----
}
! Node sfNode = doc.getDocumentElement().getElementsByTagName("session-factory").item(0);
String name = sfNode.getAttributes().getNamedItem("name").getNodeValue();
properties.setProperty(Environment.SESSION_FACTORY_NAME, name);
|
|
From: <one...@us...> - 2003-01-26 02:49:52
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv1599/src/net/sf/hibernate/impl Removed Files: DatastoreImpl.java Log Message: new config API --- DatastoreImpl.java DELETED --- |
|
From: <one...@us...> - 2003-01-26 02:42:12
|
Update of /cvsroot/hibernate/Hibernate2
In directory sc8-pr-cvs1:/tmp/cvs-serv32113
Modified Files:
build.xml
Log Message:
change to javadoc
Index: build.xml
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/build.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** build.xml 14 Jan 2003 14:07:00 -0000 1.3
--- build.xml 26 Jan 2003 02:42:09 -0000 1.4
***************
*** 148,154 ****
link="${javadoc}">
! <group title="Core API" packages="net.sf.hibernate:net.sf.hibernate.metadata"/>
<group title="Extension API" packages="net.sf.hibernate.id:net.sf.hibernate.connection:net.sf.hibernate.transaction:net.sf.hibernate.type:net.sf.hibernate.dialect:net.sf.hibernate.cache:net.sf.hibernate.loader:net.sf.hibernate.persister:net.sf.hibernate.engine"/>
! <group title="Extras" packages="net.sf.hibernate.odmg:net.sf.hibernate.cfg:net.sf.hibernate.jmx"/>
</javadoc>
--- 148,154 ----
link="${javadoc}">
! <group title="Core API" packages="net.sf.hibernate:net.sf.hibernate.metadata:net.sf.hibernate.cfg"/>
<group title="Extension API" packages="net.sf.hibernate.id:net.sf.hibernate.connection:net.sf.hibernate.transaction:net.sf.hibernate.type:net.sf.hibernate.dialect:net.sf.hibernate.cache:net.sf.hibernate.loader:net.sf.hibernate.persister:net.sf.hibernate.engine"/>
! <group title="Extras" packages="net.sf.hibernate.odmg:net.sf.hibernate.jmx"/>
</javadoc>
|