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-05-02 09:18:15
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv19240 Modified Files: Binder.java Log Message: added idbag and made some cleanups to collection fwk Index: Binder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Binder.java 26 Apr 2003 06:09:11 -0000 1.16 --- Binder.java 2 May 2003 09:18:11 -0000 1.17 *************** *** 9,12 **** --- 9,13 ---- import net.sf.hibernate.Hibernate; import net.sf.hibernate.MappingException; + import net.sf.hibernate.mapping.IdentifierBag; import net.sf.hibernate.engine.Cascades; import net.sf.hibernate.id.PersistentIdentifierGenerator; *************** *** 20,23 **** --- 21,25 ---- import net.sf.hibernate.mapping.Component; import net.sf.hibernate.mapping.ForeignKey; + import net.sf.hibernate.mapping.IdentifierCollection; import net.sf.hibernate.mapping.IndexedCollection; import net.sf.hibernate.mapping.IntegerValue; *************** *** 445,448 **** --- 447,453 ---- mappings.addSecondPass( new MapSecondPass(node, mappings, (Map) model) ); } + else if (model instanceof IdentifierCollection) { + mappings.addSecondPass( new IdentifierCollectionSecondPass(node, mappings, (IdentifierCollection) model) ); + } else { mappings.addSecondPass( new CollectionSecondPass(node, mappings, model) ); *************** *** 878,881 **** --- 883,899 ---- } + + public static void bindIdentifierCollectionSecondPass(Element node, IdentifierCollection model, java.util.Map persistentClasses, Mappings mappings) throws MappingException { + + bindCollectionSecondPass(node, model, persistentClasses, mappings); + + Element subnode = node.element("collection-id"); + Value id = new Value( model.getTable() ); + bindValue(subnode, id, false, IdentifierCollection.DEFAULT_IDENTIFIER_COLUMN_NAME); + model.setIdentifier(id); + makeIdentifier(subnode, id, mappings); + if ( !model.isOneToMany() ) model.createPrimaryKey(); + + } /** *************** *** 958,962 **** ManyToOne element = new ManyToOne( model.getTable() ); model.setElement(element); ! bindManyToOne(subnode, element, Collection.DEFAULT_ELEMENT_COLUMN_NAME, true); } else if ( "composite-element".equals(name) ) { --- 976,980 ---- ManyToOne element = new ManyToOne( model.getTable() ); model.setElement(element); ! bindManyToOne(subnode, element, Collection.DEFAULT_ELEMENT_COLUMN_NAME, false); } else if ( "composite-element".equals(name) ) { *************** *** 1055,1058 **** --- 1073,1086 ---- } + static class IdentifierCollectionSecondPass extends SecondPass { + IdentifierCollectionSecondPass(Element node, Mappings mappings, IdentifierCollection collection) { + super(node, mappings, collection); + } + void secondPass(java.util.Map persistentClasses) throws MappingException { + Binder.bindIdentifierCollectionSecondPass( node, (IdentifierCollection) collection, persistentClasses, mappings ); + } + + } + static class MapSecondPass extends SecondPass { MapSecondPass(Element node, Mappings mappings, Map collection) { *************** *** 1123,1126 **** --- 1151,1161 ---- } }; + private static final CollectionType IDBAG = new CollectionType("idbag") { + public Collection create(Element node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException { + IdentifierBag bag = new IdentifierBag(owner); + Binder.bindCollection(node, bag, prefix, mappings); + return bag; + } + }; private static final CollectionType ARRAY = new CollectionType("array") { public Collection create(Element node, String prefix, PersistentClass owner, Mappings mappings) throws MappingException { *************** *** 1141,1144 **** --- 1176,1180 ---- INSTANCES.put(MAP.toString(), MAP); INSTANCES.put(BAG.toString(), BAG); + INSTANCES.put(IDBAG.toString(), IDBAG); INSTANCES.put(SET.toString(), SET); INSTANCES.put(LIST.toString(), LIST); |
From: <one...@us...> - 2003-05-02 09:17:28
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv19050 Modified Files: TypeFactory.java Added Files: IdentifierBagType.java Log Message: added idbag and made some cleanups to collection fwk --- NEW FILE: IdentifierBagType.java --- //$Id: IdentifierBagType.java,v 1.1 2003/05/02 09:17:13 oneovthafew Exp $ package net.sf.hibernate.type; import java.io.Serializable; import net.sf.hibernate.HibernateException; import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.collection.IdentifierBag; import net.sf.hibernate.collection.PersistentCollection; import net.sf.hibernate.engine.SessionImplementor; public class IdentifierBagType extends PersistentCollectionType { public IdentifierBagType(String role) { super(role); } protected PersistentCollection instantiate( SessionImplementor session, CollectionPersister persister) throws HibernateException { return new IdentifierBag(session); } public Class getReturnedClass() { return java.util.Collection.class; } public PersistentCollection wrap(SessionImplementor session, Object collection) { return new IdentifierBag( session, (java.util.Collection) collection ); } public PersistentCollection assembleCachedCollection( SessionImplementor session, CollectionPersister persister, Serializable disassembled, Object owner) throws HibernateException { return new IdentifierBag(session, persister, disassembled, owner); } } Index: TypeFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/TypeFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TypeFactory.java 25 Apr 2003 03:40:37 -0000 1.8 --- TypeFactory.java 2 May 2003 09:17:14 -0000 1.9 *************** *** 173,176 **** --- 173,179 ---- return new BagType(role); } + public static PersistentCollectionType idbag(String role) { + return new IdentifierBagType(role); + } public static PersistentCollectionType map(String role) { return new MapType(role); |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping In directory sc8-pr-cvs1:/tmp/cvs-serv18728 Modified Files: Bag.java Collection.java List.java Value.java Added Files: IdentifierBag.java IdentifierCollection.java Log Message: added idbag and made some cleanups to collection fwk --- NEW FILE: IdentifierBag.java --- //$Id: IdentifierBag.java,v 1.1 2003/05/02 09:16:14 oneovthafew Exp $ package net.sf.hibernate.mapping; import net.sf.hibernate.type.PersistentCollectionType; import net.sf.hibernate.type.TypeFactory; /** * An <tt>IdentifierBag</tt> has a primary key consisting of just * the identifier column */ public class IdentifierBag extends IdentifierCollection { public IdentifierBag(PersistentClass owner) { super(owner); } public PersistentCollectionType getType() { return TypeFactory.idbag( getRole() ); } public Class wrapperClass() { return net.sf.hibernate.collection.IdentifierBag.class; } } --- NEW FILE: IdentifierCollection.java --- //$Id: IdentifierCollection.java,v 1.1 2003/05/02 09:16:14 oneovthafew Exp $ package net.sf.hibernate.mapping; import java.util.Iterator; /** * A collection with a synthetic "identifier" column */ public abstract class IdentifierCollection extends Collection { public static final String DEFAULT_IDENTIFIER_COLUMN_NAME = "id"; private Value identifier; public IdentifierCollection(PersistentClass owner) { super(owner); } public Value getIdentifier() { return identifier; } public void setIdentifier(Value index) { this.identifier = index; } public final boolean isIdentified() { return true; } public void createPrimaryKey() { PrimaryKey pk = new PrimaryKey(); Iterator iter = getIdentifier().getColumnIterator(); while ( iter.hasNext() ) { pk.addColumn( (Column) iter.next() ); } getTable().setPrimaryKey(pk); } } Index: Bag.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Bag.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Bag.java 27 Jan 2003 12:12:41 -0000 1.5 --- Bag.java 2 May 2003 09:16:13 -0000 1.6 *************** *** 10,17 **** public class Bag extends Collection { - /** - * Constructor for Bag. - * @param owner - */ public Bag(PersistentClass owner) { super(owner); --- 10,13 ---- Index: Collection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Collection.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Collection.java 15 Feb 2003 01:00:55 -0000 1.13 --- Collection.java 2 May 2003 09:16:14 -0000 1.14 *************** *** 229,232 **** --- 229,236 ---- } + public boolean isIdentified() { + return false; + } + } Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/List.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** List.java 27 Jan 2003 12:12:41 -0000 1.6 --- List.java 2 May 2003 09:16:14 -0000 1.7 *************** *** 11,18 **** public class List extends IndexedCollection { - /** - * Constructor for List. - * @param owner - */ public List(PersistentClass owner) { super(owner); --- 11,14 ---- Index: Value.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Value.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Value.java 29 Mar 2003 04:08:47 -0000 1.10 --- Value.java 2 May 2003 09:16:14 -0000 1.11 *************** *** 101,108 **** } - public String getIdentifierStrategy() { - return identifierGeneratorStrategy; - } - public Properties getIdentifierGeneratorProperties() { return identifierGeneratorProperties; --- 101,104 ---- |
From: <one...@us...> - 2003-05-02 09:14:39
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv17954 Modified Files: ArrayHolder.java Bag.java CollectionPersister.java List.java Map.java PersistentCollection.java Set.java Added Files: IdentifierBag.java Log Message: added idbag and made some cleanups to collection fwk --- NEW FILE: IdentifierBag.java --- package net.sf.hibernate.collection; import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import net.sf.hibernate.HibernateException; import net.sf.hibernate.JDBCException; import net.sf.hibernate.engine.SessionImplementor; import net.sf.hibernate.type.Type; /** * An <tt>IdentifierBag</tt> implements "bag" semantics more efficiently than * a regular <tt>Bag</tt> by adding a synthetic identifier column to the * table. This identifier is unique for all rows in the table, allowing very * efficient updates and deletes. The value of the identifier is never exposed * to the application.<br> * <br> * <tt>IdentifierBag</tt>s may not be used for a many-to-one association. * Furthermore, there is no reason to use <tt>inverse="true"</tt>. * * @author Gavin King */ public class IdentifierBag extends ODMGCollection implements java.util.List { private java.util.List values; private java.util.Map identifiers; //element -> id public IdentifierBag(SessionImplementor session) { super(session); } public IdentifierBag(SessionImplementor session, java.util.Collection coll) { super(session); if (coll instanceof java.util.List) { values = (java.util.List) coll; } else { values = new ArrayList(); Iterator iter = coll.iterator(); while ( iter.hasNext() ) { values.add( iter.next() ); } } initialized = true; directlyAccessible = true; identifiers = new HashMap(); } public IdentifierBag(SessionImplementor session, CollectionPersister persister, Serializable disassembled, Object owner) throws HibernateException { super(session); beforeInitialize(persister); Serializable[] array = (Serializable[]) disassembled; for (int i=0; i<array.length; i+=2 ) { Object value = persister.getElementType().assemble( array[i+1], session, owner ); identifiers.put( value, persister.getIdentifierType().assemble( array[i], session, owner ) ); values.add(value); } initialized=true; } public boolean add(Object o) { write(); values.add(o); return true; } public void clear() { write(); values.clear(); identifiers.clear(); } public boolean contains(Object o) { read(); return values.contains(o); } public boolean containsAll(Collection c) { read(); return values.containsAll(c); } public boolean isEmpty() { read(); return values.isEmpty(); } public Iterator iterator() { read(); return values.iterator(); } public boolean remove(Object o) { write(); return values.remove(o); } public boolean removeAll(Collection c) { if ( c.size()>0 ) { write(); return values.removeAll(c); } else { return false; } } public boolean retainAll(Collection c) { write(); return values.retainAll(c); } public int size() { read(); return values.size(); } public Object[] toArray() { read(); return values.toArray(); } public Object[] toArray(Object[] a) { read(); return values.toArray(); } public void beforeInitialize(CollectionPersister persister) { identifiers = new HashMap(); values = new ArrayList(); } public Serializable disassemble(CollectionPersister persister) throws HibernateException { Serializable[] result = new Serializable[ values.size() * 2 ]; Iterator iter = values.iterator(); int i=0; while ( iter.hasNext() ) { Object value = iter.next(); result[i++] = persister.getIdentifierType().disassemble( identifiers.get(value), session); result[i++] = persister.getElementType().disassemble( value, session ); } return result; } public Iterator elements() { return values.iterator(); } public boolean empty() { return values.isEmpty(); } public Iterator entries() { return values.iterator(); } public boolean entryExists(Object entry, int i) { return entry!=null; } public boolean equalsSnapshot(Type elementType) throws HibernateException { java.util.Map snap = (java.util.Map) getSnapshot(); if ( snap.size()!= values.size() ) return false; Iterator iter = values.iterator(); int i=0; while ( iter.hasNext() ) { Object value = iter.next(); Object id = identifiers.get( new Integer(i++) ); if (id==null) return false; Object old = snap.get(id); if ( elementType.isDirty(old, value, session) ) return false; } return true; } public Iterator getDeletes(Type elemType) throws HibernateException { java.util.Map snap = (java.util.Map) getSnapshot(); java.util.List deletes = new ArrayList( snap.keySet() ); Iterator iter = values.iterator(); int i=0; while ( iter.hasNext() ) { if ( iter.next()!=null ) deletes.remove( identifiers.get( new Integer(i++) ) ); } return deletes.iterator(); } public Object getIndex(Object entry, int i) { throw new UnsupportedOperationException("Bags don't have indexes"); } public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { java.util.Map snap = (java.util.Map) getSnapshot(); Object id = identifiers.get( new Integer(i) ); return entry!=null && ( id==null || snap.get(id)==null ); } public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException { if (entry==null) return false; java.util.Map snap = (java.util.Map) getSnapshot(); Object id = identifiers.get( new Integer(i) ); if (id==null) return false; Object old = snap.get(id); return entry!=null && old!=null && elemType.isDirty(old, entry, session); } public Object readFrom( ResultSet rs, CollectionPersister persister, Object owner) throws HibernateException, SQLException { Object element = persister.readElement(rs, owner, session); values.add(element); identifiers.put( new Integer( values.size()-1), persister.readIdentifier(rs, session) ); return element; } protected Serializable snapshot(CollectionPersister persister) throws HibernateException { HashMap map = new HashMap( values.size() ); Iterator iter = values.iterator(); int i=0; while ( iter.hasNext() ) { Object value = iter.next(); map.put( identifiers.get( new Integer(i++) ), persister.getElementType().deepCopy(value) ); } return map; } public void preInsert(CollectionPersister persister, Object entry, int i) throws HibernateException { try { Serializable id = persister.getIdentifierGenerator().generate(session, entry); //TODO: native ids identifiers.put( new Integer(i), id ); } catch (SQLException sqle) { throw new JDBCException("could not generate collection row id", sqle); } } public void writeTo( PreparedStatement st, CollectionPersister persister, Object entry, int i, boolean writeOrder) throws HibernateException, SQLException { persister.writeElement(st, entry, writeOrder, session); persister.writeIdentifier(st, identifiers.get( new Integer(i) ), writeOrder, session); } public void add(int index, Object element) { write(); values.add(index, element); } public boolean addAll(int index, Collection c) { if ( c.size()>0 ) { write(); return values.addAll(index, c); } else { return false; } } public Object get(int index) { read(); return values.get(index); } public int indexOf(Object o) { read(); return values.indexOf(o); } public int lastIndexOf(Object o) { read(); return values.lastIndexOf(o); } public ListIterator listIterator() { read(); return values.listIterator(); } public ListIterator listIterator(int index) { read(); return values.listIterator(index); } public Object remove(int index) { write(); return values.remove(index); } public Object set(int index, Object element) { write(); return values.set(index, element); } public List subList(int fromIndex, int toIndex) { read(); return values.subList(fromIndex, toIndex); } public boolean addAll(Collection c) { if ( c.size()> 0 ) { write(); return values.addAll(c); } else { return false; } } } Index: ArrayHolder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/ArrayHolder.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ArrayHolder.java 25 Apr 2003 03:40:30 -0000 1.13 --- ArrayHolder.java 2 May 2003 09:14:29 -0000 1.14 *************** *** 73,89 **** /** - * @see PersistentCollection#replaceElements(Map) - */ - public void replaceElements(java.util.Map replacements) { - int size = Array.getLength(array); - for (int i=0; i<size; i++) { - Object val = Array.get(array, i); - Object r; - if ( val!=null && ( r=replacements.get(val) )!=null ) - Array.set(array, i, r); - } - } - - /** * @see PersistentCollection#elements() */ --- 73,76 ---- *************** *** 133,149 **** public Iterator entries() { return elements(); - } - - public void readEntries(Iterator entries) { - ArrayList list = new ArrayList(); - while ( entries.hasNext() ) { - list.add( entries.next() ); - } - array = Array.newInstance( elementClass, list.size() ); - entries = list.iterator(); - int i=0; - while ( entries.hasNext() ) { - Array.set( array, i++, entries.next() ); - } } --- 120,123 ---- Index: Bag.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Bag.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Bag.java 25 Apr 2003 03:40:30 -0000 1.12 --- Bag.java 2 May 2003 09:14:29 -0000 1.13 *************** *** 11,15 **** import java.util.List; import java.util.ListIterator; - import java.util.Map; import org.odmg.DBag; --- 11,14 ---- *************** *** 63,77 **** /** - * @see net.sf.hibernate.collections.PersistentCollection#replaceElements(Map) - */ - public void replaceElements(Map replacements) throws HibernateException { - for (int i=0; i<size(); i++) { - Object val = bag.get(i); - Object r; - if ( val!=null && ( r = replacements.get(val) )!=null ) bag.set(i, r); - } - } - - /** * @see net.sf.hibernate.collections.PersistentCollection#entries() */ --- 62,65 ---- *************** *** 80,91 **** } - /** - * @see net.sf.hibernate.collections.PersistentCollection#readEntries(Iterator) - */ - public void readEntries(Iterator entries) { - while ( entries.hasNext() ) { - bag.add( entries.next() ); - } - } /** --- 68,71 ---- *************** *** 276,279 **** --- 256,260 ---- */ public boolean addAll(Collection c) { + if ( c.size()==0 ) return false; if ( !queueAddAll(c) ) { write(); *************** *** 285,294 **** } /** * @see java.util.Collection#removeAll(Collection) */ public boolean removeAll(Collection c) { ! write(); ! return bag.removeAll(c); } --- 266,284 ---- } + public void delayedAddAll(Collection c) { + bag.addAll(c); + } + /** * @see java.util.Collection#removeAll(Collection) */ public boolean removeAll(Collection c) { ! if ( c.size()>0 ) { ! write(); ! return bag.removeAll(c); ! } ! else { ! return false; ! } } *************** *** 351,392 **** } - /*public boolean add(Object o, int n) { - if (n>0) write(); - for (int i=0; i<n; i++) { - add(o); - } - return n>0; - } - - public boolean remove(Object o, int n) { - if (n>0) write(); - for (int i=0; i<n; i++) { - remove(o); - } - return n>0; - } - - public Set uniqueSet() { - Set set = new HashSet( bag.size() ); - Iterator iter = bag.iterator(); - while ( iter.hasNext() ) { - set.add( iter.next() ); - } - return set; - } - - public int removeAllOccurences(Object o) { - write(); - Iterator iter = bag.iterator(); - int result=0; - while ( iter.hasNext() ) { - if ( o.equals( iter.next() ) ) { - result++; - iter.remove(); - } - } - return result; - }*/ - // List OPERATIONS: --- 341,344 ---- *************** *** 403,408 **** */ public boolean addAll(int i, Collection c) { ! write(); ! return bag.addAll(i, c); } --- 355,365 ---- */ public boolean addAll(int i, Collection c) { ! if ( c.size()>0 ) { ! write(); ! return bag.addAll(i, c); ! } ! else { ! return false; ! } } Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/CollectionPersister.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** CollectionPersister.java 25 Apr 2003 03:40:30 -0000 1.21 --- CollectionPersister.java 2 May 2003 09:14:29 -0000 1.22 *************** *** 17,20 **** --- 17,21 ---- import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; + import net.sf.hibernate.id.IdentifierGenerator; import net.sf.hibernate.loader.CollectionInitializer; import net.sf.hibernate.loader.CollectionLoader; *************** *** 23,26 **** --- 24,28 ---- import net.sf.hibernate.mapping.Collection; import net.sf.hibernate.mapping.Column; + import net.sf.hibernate.mapping.IdentifierCollection; import net.sf.hibernate.mapping.IndexedCollection; import net.sf.hibernate.mapping.PersistentClass; *************** *** 74,81 **** private final String[] unquotedIndexColumnNames; private final String[] unquotedElementColumnNames; ! private final String[] rowSelectColumnNames; private final String[] indexColumnAliases; private final String[] elementColumnAliases; ! private final Type rowSelectType; private final boolean primitiveArray; private final boolean array; --- 76,83 ---- private final String[] unquotedIndexColumnNames; private final String[] unquotedElementColumnNames; ! private String[] rowSelectColumnNames; //TODO: make final again private final String[] indexColumnAliases; private final String[] elementColumnAliases; ! private Type rowSelectType; //TODO: make final again private final boolean primitiveArray; private final boolean array; *************** *** 91,94 **** --- 93,102 ---- private final Class ownerClass; //private final boolean isSorted; + private final IdentifierGenerator identifierGenerator; + private final String unquotedIdentifierColumnName; + private final Type identifierType; + private final boolean hasIdentifier; + private final String identifierColumnName; + private final String identifierColumnAlias; private final CollectionInitializer loader; *************** *** 189,192 **** --- 197,220 ---- } + if ( hasIdentifier = collection.isIdentified() ) { + if (isOneToMany) throw new MappingException("one-to-many collections with identifiers are not supported"); + IdentifierCollection idColl = (IdentifierCollection) collection; + identifierType = idColl.getIdentifier().getType(); + iter = idColl.getIdentifier().getColumnIterator(); + identifierColumnName = ( (Column) iter.next() ).getName(); + rowSelectColumnNames = new String[] { identifierColumnName }; + rowSelectType = identifierType; + identifierColumnAlias = alias.toAliasString(identifierColumnName); + unquotedIdentifierColumnName = StringHelper.unQuote(identifierColumnAlias); + identifierGenerator = idColl.getIdentifier().createIdentifierGenerator( factory.getDialect() ); + } + else { + identifierType = null; + identifierColumnName = null; + identifierColumnAlias = null; + unquotedIdentifierColumnName = null; + identifierGenerator = null; + } + //sqlSelectString = sqlSelectString(); sqlDeleteString = generateDeleteString(); *************** *** 348,354 **** } public void writeElement(PreparedStatement st, Object elt, boolean writeOrder, SessionImplementor session) throws HibernateException, SQLException { ! getElementType().nullSafeSet(st, elt, 1+(writeOrder?0:keyColumnNames.length+(hasIndex?indexColumnNames.length:0)), session); } --- 376,393 ---- } + public Object readIdentifier(ResultSet rs, SessionImplementor session) throws HibernateException, SQLException { + Object id = getIdentifierType().nullSafeGet(rs, unquotedIdentifierColumnName, session, null); + if (id==null) throw new HibernateException("null identifier column for collection: " + role); + return id; + } + public void writeElement(PreparedStatement st, Object elt, boolean writeOrder, SessionImplementor session) throws HibernateException, SQLException { ! getElementType().nullSafeSet( ! st, ! elt, ! 1+(writeOrder?0:keyColumnNames.length+(hasIndex?indexColumnNames.length:0)+(hasIdentifier?1:0)), ! session ! ); } *************** *** 358,364 **** } private void writeRowSelect(PreparedStatement st, Object idx, SessionImplementor session) throws HibernateException, SQLException { ! rowSelectType.nullSafeSet(st, idx, 1+keyColumnNames.length, session); } --- 397,408 ---- } + public void writeIdentifier(PreparedStatement st, Object idx, boolean writeOrder, SessionImplementor session) + throws HibernateException, SQLException { + getIdentifierType().nullSafeSet(st, idx, 1+(writeOrder?elementColumnNames.length:keyColumnNames.length), session); + } + private void writeRowSelect(PreparedStatement st, Object idx, SessionImplementor session) throws HibernateException, SQLException { ! rowSelectType.nullSafeSet(st, idx, 1+(hasIdentifier?0:keyColumnNames.length), session); } *************** *** 385,388 **** --- 429,433 ---- .addColumns(alias, elementColumnNames, elementColumnAliases); if (hasIndex) frag.addColumns(alias, indexColumnNames, indexColumnAliases); + if (hasIdentifier) frag.addColumn(alias, identifierColumnName, identifierColumnAlias); return frag.toFragmentString() .substring(2); //strip leading ',' *************** *** 425,429 **** .setTableName(qualifiedTableName) .addColumns(keyColumnNames); ! if (hasIndex) update.addColumns(indexColumnNames); return update.setPrimaryKeyColumnNames(elementColumnNames) .toStatementString(); --- 470,475 ---- .setTableName(qualifiedTableName) .addColumns(keyColumnNames); ! if (hasIndex) update.addColumns(indexColumnNames); ! //identifier collections not supported for 1-to-many return update.setPrimaryKeyColumnNames(elementColumnNames) .toStatementString(); *************** *** 434,437 **** --- 480,484 ---- .addColumns(keyColumnNames); if (hasIndex) insert.addColumns(indexColumnNames); + if (hasIdentifier) insert.addColumn(identifierColumnName); return insert.addColumns(elementColumnNames) .toStatementString(); *************** *** 444,457 **** } else { ! return new Update() .setTableName(qualifiedTableName) ! .addColumns(elementColumnNames) ! .setPrimaryKeyColumnNames( ArrayHelper.join(keyColumnNames, rowSelectColumnNames) ) ! .toStatementString(); } } private String generateDeleteRowString() { ! String[] pkColumns = ArrayHelper.join(keyColumnNames, rowSelectColumnNames); if (isOneToMany) { Update update = new Update() --- 491,515 ---- } else { ! Update update = new Update() .setTableName(qualifiedTableName) ! .addColumns(elementColumnNames); ! if (hasIdentifier) { ! update.setPrimaryKeyColumnNames(rowSelectColumnNames); ! } ! else { ! update.setPrimaryKeyColumnNames( ArrayHelper.join(keyColumnNames, rowSelectColumnNames) ); ! } ! return update.toStatementString(); } } private String generateDeleteRowString() { ! final String[] pkColumns; ! if (hasIdentifier) { ! pkColumns = rowSelectColumnNames; ! } ! else { ! pkColumns = ArrayHelper.join(keyColumnNames, rowSelectColumnNames); ! } if (isOneToMany) { Update update = new Update() *************** *** 544,547 **** --- 602,606 ---- Object entry = entries.next(); if ( collection.entryExists(entry, i) ) { + collection.preInsert(this, entry, i); //TODO (Big): this here screws up batching! writeKey(st, id, false, session); collection.writeTo(st, this, entry, i, false); *************** *** 579,583 **** try { while ( entries.hasNext() ) { ! writeKey(st, id, false, session ); writeRowSelect( st, entries.next(), session ); session.getBatcher().addToBatch(-1); --- 638,642 ---- try { while ( entries.hasNext() ) { ! if (!hasIdentifier) writeKey(st, id, false, session ); writeRowSelect( st, entries.next(), session ); session.getBatcher().addToBatch(-1); *************** *** 607,611 **** if ( collection.needsUpdating(entry, i, elementType) ) { if (st==null) st = session.getBatcher().prepareBatchStatement( getSQLUpdateRowString() ); ! writeKey(st, id, true, session); collection.writeTo( st, this, entry, i, true ); session.getBatcher().addToBatch(1); --- 666,670 ---- if ( collection.needsUpdating(entry, i, elementType) ) { if (st==null) st = session.getBatcher().prepareBatchStatement( getSQLUpdateRowString() ); ! if (!hasIdentifier) writeKey(st, id, true, session); collection.writeTo( st, this, entry, i, true ); session.getBatcher().addToBatch(1); *************** *** 697,700 **** --- 756,760 ---- Object entry = entries.next(); if ( collection.needsInserting(entry, i, elementType) ) { + collection.preInsert(this, entry, i); //TODO (Big): this here screws up batching! if (st==null) st = session.getBatcher().prepareBatchStatement( getSQLInsertRowString() ); writeKey(st, id, false, session); *************** *** 731,734 **** --- 791,805 ---- }*/ + public IdentifierGenerator getIdentifierGenerator() { + return identifierGenerator; + } + + public Type getIdentifierType() { + return identifierType; + } + + public boolean hasIdentifier() { + return hasIdentifier; + } } Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/List.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** List.java 27 Apr 2003 07:04:30 -0000 1.13 --- List.java 2 May 2003 09:14:30 -0000 1.14 *************** *** 145,148 **** --- 145,149 ---- */ public boolean addAll(Collection c) { + if ( c.size()==0 ) return false; if ( !queueAddAll(c) ) { write(); *************** *** 154,163 **** } /** * @see List#addAll(int, Collection) */ ! public boolean addAll(int arg0, Collection arg1) { ! write(); ! return list.addAll( arg0, arg1); } --- 155,173 ---- } + public void delayedAddAll(Collection c) { + list.addAll(c); + } + /** * @see List#addAll(int, Collection) */ ! public boolean addAll(int index, Collection coll) { ! if ( coll.size()>0 ) { ! write(); ! return list.addAll(index, coll); ! } ! else { ! return false; ! } } *************** *** 165,171 **** * @see List#removeAll(Collection) */ ! public boolean removeAll(Collection arg0) { ! write(); ! return list.removeAll( arg0); } --- 175,186 ---- * @see List#removeAll(Collection) */ ! public boolean removeAll(Collection coll) { ! if ( coll.size()>0 ) { ! write(); ! return list.removeAll(coll); ! } ! else { ! return false; ! } } *************** *** 173,179 **** * @see List#retainAll(Collection) */ ! public boolean retainAll(Collection arg0) { write(); ! return list.retainAll( arg0); } --- 188,194 ---- * @see List#retainAll(Collection) */ ! public boolean retainAll(Collection coll) { write(); ! return list.retainAll(coll); } *************** *** 259,273 **** /** - * @see PersistentCollection#replaceElements(Map) - */ - public void replaceElements(java.util.Map replacements) { - for (int i=0; i<size(); i++) { - Object val = list.get(i); - Object r; - if ( val!=null && ( r = replacements.get(val) )!=null ) list.set(i, r); - } - } - - /** * @see PersistentCollection#elements() */ --- 274,277 ---- *************** *** 312,321 **** public Iterator entries() { return list.iterator(); - } - - public void readEntries(Iterator entries) { - while ( entries.hasNext() ) { - list.add( entries.next() ); - } } --- 316,319 ---- Index: Map.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Map.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Map.java 27 Apr 2003 07:04:30 -0000 1.13 --- Map.java 2 May 2003 09:14:30 -0000 1.14 *************** *** 125,131 **** * @see Map#putAll(Map) */ ! public void putAll(java.util.Map arg0) { ! write(); ! map.putAll(arg0); } --- 125,133 ---- * @see Map#putAll(Map) */ ! public void putAll(java.util.Map puts) { ! if ( map.size()>0 ) { ! write(); ! map.putAll(puts); ! } } *************** *** 163,182 **** /** - * @see PersistentCollection#replaceElements(Map) - */ - public void replaceElements(java.util.Map replacements) throws HibernateException { - Iterator iter = map.entrySet().iterator(); - int n=0; - while ( iter.hasNext() ) { - java.util.Map.Entry e = (java.util.Map.Entry) iter.next(); - Object val = e.getValue(); - Object r; - if ( val!=null && ( r=replacements.get(val) )!=null ) e.setValue(r); - n++; - } - if ( n!=replacements.size() ) throw new HibernateException("Application error: don't use mutable values for keys of maps"); - } - - /** * @see PersistentCollection#elements() */ --- 165,168 ---- *************** *** 219,229 **** } - public void readEntries(Iterator entries) { - while ( entries.hasNext() ) { - java.util.Map.Entry e = (java.util.Map.Entry) entries.next(); - map.put( e.getKey(), e.getValue() ); - } - } - /** a wrapper for Map.Entry sets */ class EntrySetProxy implements java.util.Set { --- 205,208 ---- *************** *** 320,324 **** for (int i=0; i<array.length; i+=2 ) map.put( persister.getIndexType().assemble( array[i], session, owner ), ! persister.getElementType().assemble( array[i+1], session, owner ) //TODO: fix the null!!!! ); initialized = true; --- 299,303 ---- for (int i=0; i<array.length; i+=2 ) map.put( persister.getIndexType().assemble( array[i], session, owner ), ! persister.getElementType().assemble( array[i+1], session, owner ) ); initialized = true; Index: PersistentCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/PersistentCollection.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PersistentCollection.java 25 Apr 2003 03:40:31 -0000 1.14 --- PersistentCollection.java 2 May 2003 09:14:30 -0000 1.15 *************** *** 61,66 **** public abstract boolean empty(); - public abstract void replaceElements(java.util.Map replacements) throws HibernateException; - public final void read() { initialize(false); --- 61,64 ---- *************** *** 110,114 **** } ! public boolean addAll(Collection coll) { throw new AssertionFailure("Collection does not support delayed initialization"); } --- 108,112 ---- } ! public void delayedAddAll(Collection coll) { throw new AssertionFailure("Collection does not support delayed initialization"); } *************** *** 148,152 **** //do this bit after setting initialized to true or it will recurse if (additions!=null) { ! addAll(additions); additions=null; } --- 146,150 ---- //do this bit after setting initialized to true or it will recurse if (additions!=null) { ! delayedAddAll(additions); additions=null; } *************** *** 195,199 **** public abstract Iterator entries(); - public abstract void readEntries(Iterator entries); public abstract Object readFrom(ResultSet rs, CollectionPersister role, Object owner) throws HibernateException, SQLException; public abstract void writeTo(PreparedStatement st, CollectionPersister role, Object entry, int i, boolean writeOrder) throws HibernateException, SQLException; --- 193,196 ---- *************** *** 566,569 **** --- 563,568 ---- this.collectionSnapshot = collectionSnapshot; } + + public void preInsert(CollectionPersister persister, Object entry, int i) throws HibernateException {} } Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Set.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Set.java 27 Apr 2003 07:04:30 -0000 1.13 --- Set.java 2 May 2003 09:14:30 -0000 1.14 *************** *** 6,10 **** import java.util.HashMap; import java.util.Iterator; - import java.util.Map; import java.util.HashSet; import java.io.Serializable; --- 6,9 ---- *************** *** 87,104 **** /** - * @see PersistentCollection#replaceElements(Map) - */ - public void replaceElements(Map replacements) throws HibernateException { - Iterator iter = replacements.entrySet().iterator(); - while ( iter.hasNext() ) { - java.util.Map.Entry e = (java.util.Map.Entry) iter.next(); - if ( !set.remove( e.getKey() ) ) { - throw new HibernateException("Application error: the hashcode of a mutable element of a set changed"); - } - set.add( e.getValue() ); - } - } - - /** * @see PersistentCollection#elements() */ --- 86,89 ---- *************** *** 185,191 **** * @see Set#addAll(Collection) */ ! public boolean addAll(Collection arg0) { ! write(); ! return set.addAll(arg0); } --- 170,181 ---- * @see Set#addAll(Collection) */ ! public boolean addAll(Collection coll) { ! if ( coll.size()> 0 ) { ! write(); ! return set.addAll(coll); ! } ! else { ! return false; ! } } *************** *** 201,207 **** * @see Set#removeAll(Collection) */ ! public boolean removeAll(Collection arg0) { ! write(); ! return set.remove(arg0); } --- 191,202 ---- * @see Set#removeAll(Collection) */ ! public boolean removeAll(Collection coll) { ! if ( coll.size()>0 ) { ! write(); ! return set.remove(coll); ! } ! else { ! return false; ! } } *************** *** 251,260 **** public Iterator entries() { return set.iterator(); - } - - public void readEntries(Iterator entries) { - while ( entries.hasNext() ) { - set.add( entries.next() ); - } } --- 246,249 ---- |
From: <one...@us...> - 2003-05-01 07:53:28
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv729/doc/reference/src Modified Files: manipulating_data.xml Log Message: doco for metadata API Index: manipulating_data.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/manipulating_data.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** manipulating_data.xml 26 Apr 2003 03:58:29 -0000 1.9 --- manipulating_data.xml 1 May 2003 07:53:20 -0000 1.10 *************** *** 1119,1124 **** </sect1> ! <sect1 id="manipulating-data-s16"> <title>Frequently Asked Questions</title> --- 1119,1157 ---- </sect1> ! <sect1 id="manipulating-data-s16"> + <title>Metadata API</title> + <para> + Hibernate requires a very rich meta-level model of all entity and value types. From time + to time, this model is very useful to the application itself. For example, the application + might use Hibernate's metadata to implement a "smart" deep-copy algorithm that understands + which objects should be copied (eg. mutable value types) and which should not (eg. + immutable value types and, possibly, associated entities). + </para> + <para> + Hibernate exposes metadata via the <literal>ClassMetadata</literal> and + <literal>CollectionMetadata</literal> interfaces and the <literal>Type</literal> + hierarchy. Instances of the metadata interfaces may be obtained from the + <literal>SessionFactory</literal>. + </para> + + <programlisting><![CDATA[Cat fritz = ......; + Long id = (Long) catMeta.getIdentifier(fritz); + ClassMetadata catMeta = sessionfactory.getClassMetadata(Cat.class); + Object[] propertyValues = catMeta.getPropertyValues(fritz); + String[] propertyNames = catMeta.getPropertyNames(); + Type[] propertyTypes = catMeta.getPropertyTypes(); + // get a Map of all properties which are not collections or associations + // TODO: what about components? + Map namedValues = new HashMap(); + for ( int i=0; i<propertyNames.length; i++ ) { + if ( !propertyTypes[i].isEntityType() && !propertyTypes[i].isCollectionType() ) { + namedValues.put( propertyNames[i], propertyValues[i] ); + } + }]]></programlisting> + + </sect1> + + <sect1 id="manipulating-data-s17"> <title>Frequently Asked Questions</title> |
From: <db...@us...> - 2003-05-01 02:00:58
|
Update of /cvsroot/hibernate/Hibernate2/src/META-INF In directory sc8-pr-cvs1:/tmp/cvs-serv30503/src/META-INF Modified Files: ra.xml Log Message: JCA rework from Igor Fedorenko that relies on preconfigured datasources Index: ra.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/META-INF/ra.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ra.xml 2 Mar 2003 15:28:28 -0000 1.1 --- ra.xml 1 May 2003 02:00:52 -0000 1.2 *************** *** 8,16 **** <spec-version>1.0</spec-version> <eis-type>Hibernate Sessions</eis-type> ! <version>0.9</version> <license> ! <description></description> ! <license-required></license-required> ! </license> <resourceadapter> <managedconnectionfactory-class>net.sf.hibernate.jca.ManagedConnectionFactoryImpl</managedconnectionfactory-class> --- 8,16 ---- <spec-version>1.0</spec-version> <eis-type>Hibernate Sessions</eis-type> ! <version>2.0</version> <license> ! <description></description> ! <license-required></license-required> ! </license> <resourceadapter> <managedconnectionfactory-class>net.sf.hibernate.jca.ManagedConnectionFactoryImpl</managedconnectionfactory-class> *************** *** 18,64 **** <connectionfactory-impl-class>net.sf.hibernate.jca.JCASessionFactoryImpl</connectionfactory-impl-class> <connection-interface>net.sf.hibernate.Session</connection-interface> ! <connection-impl-class>net.sf.hibernate.impl.SessionImpl</connection-impl-class> ! <transaction-support>LocalTransaction</transaction-support> <config-property> ! <config-property-name>ConnectionURL</config-property-name> <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> </config-property> <config-property> ! <config-property-name>DriverClass</config-property-name> <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> </config-property> <config-property> ! <config-property-name>UserName</config-property-name> <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> </config-property> <config-property> ! <config-property-name>Password</config-property-name> ! <config-property-type>java.lang.String</config-property-type> ! <config-property-value></config-property-value> ! </config-property> ! <config-property> ! <config-property-name>Dialect</config-property-name> ! <config-property-type>java.lang.String</config-property-type> ! <config-property-value></config-property-value> ! </config-property> ! <config-property> ! <config-property-name>MapResources</config-property-name> <config-property-type>java.lang.String</config-property-type> ! <config-property-value></config-property-value> ! </config-property> <authentication-mechanism> ! <description>BasicPassword</description> <authentication-mechanism-type>BasicPassword</authentication-mechanism-type> <credential-interface>javax.resource.security.PasswordCredential</credential-interface> </authentication-mechanism> <reauthentication-support>true</reauthentication-support> <security-permission> <description></description> <security-permission-spec> </security-permission-spec> ! </security-permission> ! </resourceadapter> </connector> --- 18,62 ---- <connectionfactory-impl-class>net.sf.hibernate.jca.JCASessionFactoryImpl</connectionfactory-impl-class> <connection-interface>net.sf.hibernate.Session</connection-interface> ! <connection-impl-class>net.sf.hibernate.jca.JCASessionImpl</connection-impl-class> ! <transaction-support>XATransaction</transaction-support> <config-property> ! <config-property-name>Dialect</config-property-name> <config-property-type>java.lang.String</config-property-type> </config-property> <config-property> ! <config-property-name>MapResources</config-property-name> <config-property-type>java.lang.String</config-property-type> </config-property> <config-property> ! <config-property-name>DatasourceJndi</config-property-name> <config-property-type>java.lang.String</config-property-type> </config-property> <config-property> ! <config-property-name>HibernateProperties</config-property-name> <config-property-type>java.lang.String</config-property-type> ! </config-property> ! <!-- ! JCA 1.0, 10.3.1 ! If no authentication mechanism is specified as part of the deployment ! descriptor, the resource adapter supports no standard security ! authentication mechanism as part of thesecurity contract. <authentication-mechanism> ! <description>BasicPassword</description> <authentication-mechanism-type>BasicPassword</authentication-mechanism-type> <credential-interface>javax.resource.security.PasswordCredential</credential-interface> </authentication-mechanism> + --> <reauthentication-support>true</reauthentication-support> + <!-- + JCA 1.0, 10.3.1 (what is that supposed to mean???) + The security permissions listed in the deployment descriptor are + different from those required by the default permission set (refer + to Section 11.2 for more details on security permissions). <security-permission> <description></description> <security-permission-spec> </security-permission-spec> ! </security-permission> ! --> ! </resourceadapter> </connector> |
From: <db...@us...> - 2003-05-01 01:59:27
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca In directory sc8-pr-cvs1:/tmp/cvs-serv29680/src/net/sf/hibernate/jca Modified Files: JCASessionImpl.java JCASessionFactoryImpl.java ManagedConnectionImpl.java ManagedConnectionFactoryImpl.java MetaDataImpl.java Removed Files: ConnectionRequestInfoImpl.java LocalTransactionImpl.java Log Message: JCA rework from Igor Fedorenko that relies on preconfigured datasources Index: JCASessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca/JCASessionImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JCASessionImpl.java 21 Apr 2003 06:28:18 -0000 1.7 --- JCASessionImpl.java 1 May 2003 01:59:23 -0000 1.8 *************** *** 17,66 **** import net.sf.hibernate.type.Type; public class JCASessionImpl implements Session { ! private Session session; private ManagedConnectionImpl mc; ! public JCASessionImpl(Session session, ManagedConnectionImpl mc){ ! this.session = session; this.mc = mc; } ! public void flush() throws HibernateException { ! session.flush(); } ! public void setFlushMode(FlushMode flushMode) { ! session.setFlushMode(flushMode); } public FlushMode getFlushMode() { ! return session.getFlushMode(); } public Connection connection() throws HibernateException { ! return session.connection(); } public Connection disconnect() throws HibernateException { ! return session.disconnect(); } public void reconnect() throws HibernateException { ! session.reconnect(); } ! public void reconnect(Connection connection) throws HibernateException { ! session.reconnect(connection); } public Connection close() throws HibernateException { mc.closeHandle(this); ! mc = null; ! return session.close(); } public boolean isOpen() { ! return session.isOpen(); } --- 17,97 ---- import net.sf.hibernate.type.Type; + /** + * A logical session handle, all real work is deligated to underlying physical + * session represented by ManagedConnectionImpl instance. + */ public class JCASessionImpl implements Session { ! /* ! * JCA 1.0 5.5.1 ! * A connection implementation class implements its methods in a ! * resource adapter implementation-specific way. It must use ! * javax.resource.spi.ManagedConnection instance as its ! * underlying physical connection. ! */ private ManagedConnectionImpl mc; ! public JCASessionImpl(final ManagedConnectionImpl mc) ! { this.mc = mc; } ! ! private Session getSession() { ! return mc.getSession(this); ! } ! ! ManagedConnectionImpl getManagedConnextion() { ! return mc; ! } ! ! void setManagedConnection(ManagedConnectionImpl mc) { ! this.mc = mc; ! } ! ! // ! // Session implementation goes below. ! // ! public void flush() throws HibernateException { ! getSession().flush(); } ! public void setFlushMode(final FlushMode flushMode) { ! getSession().setFlushMode(flushMode); } public FlushMode getFlushMode() { ! return getSession().getFlushMode(); } public Connection connection() throws HibernateException { ! return getSession().connection(); } public Connection disconnect() throws HibernateException { ! throw new UnsupportedOperationException(); } public void reconnect() throws HibernateException { ! throw new UnsupportedOperationException(); } ! public void reconnect(final Connection connection) ! throws HibernateException ! { ! throw new UnsupportedOperationException(); } public Connection close() throws HibernateException { mc.closeHandle(this); ! return null; // never let clients mess with database connections } public boolean isOpen() { ! try { ! return getSession().isOpen(); ! } catch (IllegalStateException expected) { ! return false; ! } } *************** *** 69,73 **** */ public boolean isConnected() { ! return session.isConnected(); } --- 100,104 ---- */ public boolean isConnected() { ! return getSession().isConnected(); } *************** *** 75,81 **** * @see net.sf.hibernate.Session#getIdentifier(Object) */ ! public Serializable getIdentifier(Object object) ! throws HibernateException { ! return session.getIdentifier(object); } --- 106,113 ---- * @see net.sf.hibernate.Session#getIdentifier(Object) */ ! public Serializable getIdentifier(final Object object) ! throws HibernateException ! { ! return getSession().getIdentifier(object); } *************** *** 83,89 **** * @see net.sf.hibernate.Session#load(Class, Serializable, LockMode) */ ! public Object load(Class theClass, Serializable id, LockMode lockMode) ! throws HibernateException { ! return session.load(theClass, id, lockMode); } --- 115,122 ---- * @see net.sf.hibernate.Session#load(Class, Serializable, LockMode) */ ! public Object load(final Class theClass, final Serializable id, ! final LockMode lockMode) throws HibernateException ! { ! return getSession().load(theClass, id, lockMode); } *************** *** 91,97 **** * @see net.sf.hibernate.Session#load(Class, Serializable) */ ! public Object load(Class theClass, Serializable id) ! throws HibernateException { ! return session.load(theClass, id); } --- 124,131 ---- * @see net.sf.hibernate.Session#load(Class, Serializable) */ ! public Object load(final Class theClass, final Serializable id) ! throws HibernateException ! { ! return getSession().load(theClass, id); } *************** *** 99,105 **** * @see net.sf.hibernate.Session#load(Object, Serializable) */ ! public void load(Object object, Serializable id) ! throws HibernateException { ! session.load(object, id); } --- 133,140 ---- * @see net.sf.hibernate.Session#load(Object, Serializable) */ ! public void load(final Object object, final Serializable id) ! throws HibernateException ! { ! getSession().load(object, id); } *************** *** 107,112 **** * @see net.sf.hibernate.Session#save(Object) */ ! public Serializable save(Object object) throws HibernateException { ! return session.save(object); } --- 142,147 ---- * @see net.sf.hibernate.Session#save(Object) */ ! public Serializable save(final Object object) throws HibernateException { ! return getSession().save(object); } *************** *** 114,120 **** * @see net.sf.hibernate.Session#save(Object, Serializable) */ ! public void save(Object object, Serializable id) ! throws HibernateException { ! session.save(object, id); } --- 149,156 ---- * @see net.sf.hibernate.Session#save(Object, Serializable) */ ! public void save(final Object object, final Serializable id) ! throws HibernateException ! { ! getSession().save(object, id); } *************** *** 122,127 **** * @see net.sf.hibernate.Session#saveOrUpdate(Object) */ ! public void saveOrUpdate(Object object) throws HibernateException { ! session.saveOrUpdate(object); } --- 158,163 ---- * @see net.sf.hibernate.Session#saveOrUpdate(Object) */ ! public void saveOrUpdate(final Object object) throws HibernateException { ! getSession().saveOrUpdate(object); } *************** *** 129,134 **** * @see net.sf.hibernate.Session#update(Object) */ ! public void update(Object object) throws HibernateException { ! session.update(object); } --- 165,170 ---- * @see net.sf.hibernate.Session#update(Object) */ ! public void update(final Object object) throws HibernateException { ! getSession().update(object); } *************** *** 136,262 **** * @see net.sf.hibernate.Session#update(Object, Serializable) */ ! public void update(Object object, Serializable id) ! throws HibernateException { ! session.update(object, id); } ! public void delete(Object object) throws HibernateException { ! session.delete(object); } ! public List find(String query) throws HibernateException { ! return session.find(query); } ! public List find(String query, Object value, Type type) ! throws HibernateException { ! return session.find(query, value, type); } ! public List find(String query, Object[] values, Type[] types) ! throws HibernateException { ! return session.find(query, values, types); } ! public Iterator iterate(String query) throws HibernateException { ! return session.iterate(query); } ! public Iterator iterate(String query, Object value, Type type) ! throws HibernateException { ! return session.iterate(query, value, type); } ! public Iterator iterate(String query, Object[] values, Type[] types) ! throws HibernateException { ! return session.iterate(query, values, types); } ! public Collection filter(Object collection, String filter) ! throws HibernateException { ! return session.filter(collection, filter); } ! public Collection filter( ! Object collection, ! String filter, ! Object value, ! Type type) ! throws HibernateException { return null; } ! public Collection filter( ! Object collection, ! String filter, ! Object[] values, ! Type[] types) ! throws HibernateException { ! return session.filter(collection, filter, values, types); } ! public int delete(String query) throws HibernateException { ! return session.delete(query); } ! public int delete(String query, Object value, Type type) ! throws HibernateException { ! return session.delete(query, value, type); } ! public int delete(String query, Object[] values, Type[] types) ! throws HibernateException { ! return session.delete(query, values, types); } ! public void lock(Object object, LockMode lockMode) ! throws HibernateException { ! session.lock(object, lockMode); } ! public void refresh(Object object) throws HibernateException { ! session.refresh(object); } ! public LockMode getCurrentLockMode(Object object) ! throws HibernateException { ! return session.getCurrentLockMode(object); } public Transaction beginTransaction() throws HibernateException { ! return session.beginTransaction(); } public Query createQuery(String queryString) throws HibernateException { ! return session.createQuery(queryString); } ! public Query createFilter(Object collection, String queryString) ! throws HibernateException { ! return session.createFilter(collection, queryString); } ! public Query getNamedQuery(String queryName) throws HibernateException { ! return session.getNamedQuery(queryName); ! } ! ! void setManagedConnection(ManagedConnectionImpl mc){ ! this.mc = mc; } ! public Criteria createCriteria(Class persistentClass) { ! return session.createCriteria(persistentClass); } ! public void refresh(Object object, LockMode lockMode) throws HibernateException { ! session.refresh(object, lockMode); } ! public boolean contains(Object object) { ! return session.contains(object); } public void evict(Object object) throws HibernateException { ! session.evict(object); } --- 172,303 ---- * @see net.sf.hibernate.Session#update(Object, Serializable) */ ! public void update(final Object object, final Serializable id) ! throws HibernateException ! { ! getSession().update(object, id); } ! public void delete(final Object object) throws HibernateException { ! getSession().delete(object); } ! public List find(final String query) throws HibernateException { ! return getSession().find(query); } ! public List find(final String query, final Object value, final Type type) ! throws HibernateException ! { ! return getSession().find(query, value, type); } ! public List find(final String query, final Object[] values, ! final Type[] types) throws HibernateException ! { ! return getSession().find(query, values, types); } ! public Iterator iterate(final String query) throws HibernateException { ! return getSession().iterate(query); } ! public Iterator iterate(final String query, final Object value, ! final Type type) throws HibernateException ! { ! return getSession().iterate(query, value, type); } ! public Iterator iterate(final String query, final Object[] values, ! final Type[] types) throws HibernateException ! { ! return getSession().iterate(query, values, types); } ! public Collection filter(final Object collection, final String filter) ! throws HibernateException ! { ! return getSession().filter(collection, filter); } ! public Collection filter(final Object collection, final String filter, ! final Object value, final Type type) throws HibernateException ! { return null; } ! public Collection filter(final Object collection, final String filter, ! final Object[] values, final Type[] types) throws HibernateException ! { ! return getSession().filter(collection, filter, values, types); } ! public int delete(final String query) throws HibernateException { ! return getSession().delete(query); } ! public int delete(final String query, final Object value, final Type type) ! throws HibernateException ! { ! return getSession().delete(query, value, type); } ! public int delete(final String query, final Object[] values, ! final Type[] types) throws HibernateException ! { ! return getSession().delete(query, values, types); } ! public void lock(final Object object, final LockMode lockMode) ! throws HibernateException ! { ! getSession().lock(object, lockMode); } ! public void refresh(final Object object) throws HibernateException { ! getSession().refresh(object); } ! public LockMode getCurrentLockMode(final Object object) ! throws HibernateException ! { ! return getSession().getCurrentLockMode(object); } public Transaction beginTransaction() throws HibernateException { ! throw new UnsupportedOperationException(); } public Query createQuery(String queryString) throws HibernateException { ! return getSession().createQuery(queryString); } ! public Query createFilter(final Object collection, final String queryString) ! throws HibernateException ! { ! return getSession().createFilter(collection, queryString); } ! public Query getNamedQuery(final String queryName) ! throws HibernateException ! { ! return getSession().getNamedQuery(queryName); } ! public Criteria createCriteria(final Class persistentClass) { ! return getSession().createCriteria(persistentClass); } ! public void refresh(final Object object, final LockMode lockMode) ! throws HibernateException ! { ! getSession().refresh(object, lockMode); } ! public boolean contains(final Object object) { ! return getSession().contains(object); } public void evict(Object object) throws HibernateException { ! getSession().evict(object); } Index: JCASessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca/JCASessionFactoryImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JCASessionFactoryImpl.java 8 Mar 2003 09:53:35 -0000 1.2 --- JCASessionFactoryImpl.java 1 May 2003 01:59:23 -0000 1.3 *************** *** 4,8 **** import java.sql.Connection; import java.util.Map; - import java.util.Properties; import javax.naming.NamingException; --- 4,7 ---- *************** *** 11,16 **** import javax.resource.ResourceException; import javax.resource.spi.ConnectionManager; - import javax.resource.spi.ConnectionRequestInfo; - import javax.resource.spi.ManagedConnectionFactory; import net.sf.hibernate.Databinder; --- 10,13 ---- *************** *** 19,27 **** import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; - import net.sf.hibernate.cfg.Configuration; - import net.sf.hibernate.cfg.Environment; import net.sf.hibernate.metadata.ClassMetadata; import net.sf.hibernate.metadata.CollectionMetadata; - import net.sf.hibernate.util.PropertiesHelper; import org.apache.commons.logging.Log; --- 16,21 ---- *************** *** 30,99 **** public final class JCASessionFactoryImpl implements SessionFactory, Referenceable { private static final Log log = LogFactory.getLog(JCASessionFactoryImpl.class); ! private SessionFactory factory; ! private ManagedConnectionFactory managedFactory; ! private ConnectionManager cxManager; private Reference reference; - public JCASessionFactoryImpl(ManagedConnectionFactory mcf, String dialect, String mapResources) - throws HibernateException { - this(mcf, null, dialect, mapResources); - } - public JCASessionFactoryImpl( ! ManagedConnectionFactory managedFactory, ! ConnectionManager cxManager, String dialect, String mapResources) ! throws HibernateException { ! ! Properties hibProperties = new Properties(); ! hibProperties.setProperty(Environment.DIALECT, dialect); ! ! Configuration cfg = new Configuration().addProperties(hibProperties); ! ! // taken from HibernateService, maybe factor out for JCA 1.5 ! String[] mappingFiles = PropertiesHelper.toStringArray(mapResources, " ,\n\t\r\f"); ! for ( int i=0; i<mappingFiles.length; i++ ) { ! cfg.addResource( mappingFiles[i], Thread.currentThread().getContextClassLoader() ); ! } ! this.managedFactory = managedFactory; - this.factory = cfg.buildSessionFactory(); this.cxManager = cxManager; } public void close() throws HibernateException { ! factory.close(); } public Map getAllClassMetadata() throws HibernateException { ! return factory.getAllClassMetadata(); } public Map getAllCollectionMetadata() throws HibernateException { ! return factory.getAllCollectionMetadata(); } public ClassMetadata getClassMetadata(Class persistentClass) ! throws HibernateException { ! return factory.getClassMetadata(persistentClass); } public CollectionMetadata getCollectionMetadata(String roleName) ! throws HibernateException { ! return factory.getCollectionMetadata(roleName); } public Databinder openDatabinder() throws HibernateException { ! return factory.openDatabinder(); } public Session openSession() throws HibernateException { ! Session result = null; try { ! ConnectionRequestInfo info = new ConnectionRequestInfoImpl(factory); ! result = ! (Session) cxManager.allocateConnection(managedFactory, info); } catch (ResourceException re) { throw new HibernateException(re); --- 24,90 ---- public final class JCASessionFactoryImpl implements SessionFactory, Referenceable { + + /* + * @todo JCA 1.0, 5.10.1 + * A resource adapter is required to provide support for basic error + * logging and tracing by implementing the following methods: + * - ManagedConnectionFactory.set/getLogWriter + * - ManagedConnection.set/getLogWriter + */ private static final Log log = LogFactory.getLog(JCASessionFactoryImpl.class); ! private final ManagedConnectionFactoryImpl managedFactory; ! private final ConnectionManager cxManager; private Reference reference; public JCASessionFactoryImpl( ! final ManagedConnectionFactoryImpl managedFactory, ! final ConnectionManager cxManager) throws HibernateException ! { this.managedFactory = managedFactory; this.cxManager = cxManager; } public void close() throws HibernateException { ! // don't want crazy clients to destroy the factory ! // JCA 1.5 will have adapter lifecycle management ! throw new UnsupportedOperationException(); } public Map getAllClassMetadata() throws HibernateException { ! return getSessionFactory().getAllClassMetadata(); } public Map getAllCollectionMetadata() throws HibernateException { ! return getSessionFactory().getAllCollectionMetadata(); } public ClassMetadata getClassMetadata(Class persistentClass) ! throws HibernateException ! { ! return getSessionFactory().getClassMetadata(persistentClass); } public CollectionMetadata getCollectionMetadata(String roleName) ! throws HibernateException ! { ! return getSessionFactory().getCollectionMetadata(roleName); } public Databinder openDatabinder() throws HibernateException { ! return getSessionFactory().openDatabinder(); } public Session openSession() throws HibernateException { ! JCASessionImpl result = null; try { ! // JCA 1.0, 5.5.1 ! // resource adapter implementation is not required to support the ! // mechanism for passing resource adapter-specific connection ! // request information. It can choose to pass null for ! // ConnectionRequestInfo in the allocateConnection invocation. ! result = (JCASessionImpl) ! cxManager.allocateConnection(managedFactory, null); } catch (ResourceException re) { throw new HibernateException(re); *************** *** 102,118 **** } ! public Session openSession( ! Connection connection, ! Interceptor interceptor) { ! return factory.openSession(connection, interceptor); } public Session openSession(Connection connection) { ! return factory.openSession(connection); } public Session openSession(Interceptor interceptor) ! throws HibernateException { ! return factory.openSession(interceptor); } --- 93,110 ---- } ! public Session openSession(final Connection connection, ! final Interceptor interceptor) ! { ! return getSessionFactory().openSession(connection, interceptor); } public Session openSession(Connection connection) { ! return getSessionFactory().openSession(connection); } public Session openSession(Interceptor interceptor) ! throws HibernateException ! { ! return getSessionFactory().openSession(interceptor); } *************** *** 123,126 **** --- 115,122 ---- public void setReference(Reference ref) { reference = ref; + } + + private SessionFactory getSessionFactory() { + return managedFactory.getSessionFactory(); } } Index: ManagedConnectionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca/ManagedConnectionImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ManagedConnectionImpl.java 8 Mar 2003 09:53:35 -0000 1.2 --- ManagedConnectionImpl.java 1 May 2003 01:59:23 -0000 1.3 *************** *** 7,14 **** import java.util.ArrayList; import java.util.Collection; - import java.util.HashSet; import java.util.Iterator; ! import java.util.Properties; ! import java.util.Set; import javax.resource.NotSupportedException; --- 7,12 ---- import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; ! import java.util.LinkedList; import javax.resource.NotSupportedException; *************** *** 17,21 **** import javax.resource.spi.ConnectionEventListener; import javax.resource.spi.ConnectionRequestInfo; - import javax.resource.spi.IllegalStateException; import javax.resource.spi.LocalTransaction; import javax.resource.spi.ManagedConnection; --- 15,18 ---- *************** *** 23,96 **** import javax.resource.spi.ManagedConnectionMetaData; import javax.security.auth.Subject; import javax.transaction.xa.XAResource; import net.sf.hibernate.Session; ! import net.sf.hibernate.SessionFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** ! * Implementation of JCA Managed Connection. The underlying connection is a java.sql.Connecion object ! * which is passed to a Hibernate session object for the client to use. ! * ! * This is based on a JBoss LPGL generic JDBC JCA implementation ! * ! * Currently only supports LocalTransactions (XA should follow at some stage) ! * */ ! public class ManagedConnectionImpl implements ManagedConnection { private static final Log log = LogFactory.getLog(ManagedConnectionImpl.class); - // true if connection has been destroyed - private boolean destroyed; - // the factory that created this managed connection ! private ManagedConnectionFactory mcf; ! // as per JCA 1.0 spec 5.6 when this is not null then logging has been enabled ! // by the application server and we log to this writer private PrintWriter logWriter; - // factory to create sessions - private SessionFactory sessions; - - // underlying connection to the database - private Connection connection; - // registered listeners from the application server private final Collection listeners = new ArrayList(); ! // a set of JCASessionImpl handles associated with this managed connection ! private final Set handles = new HashSet(); ! ! private Properties props; ! ManagedConnectionImpl( ! ManagedConnectionFactory mcf, ! String user, ! Properties props, ! SessionFactory sessions, ! Connection connection) { ! log.trace("Constructor called with user " + user); this.mcf = mcf; - this.sessions = sessions; - this.connection = connection; - this.props = props; } /** ! * Creates and returns a new Hibernate Session * ! * Will throw a ResourceException if the session factory * fails to create a session */ ! public Object getConnection( ! Subject subject, ! ConnectionRequestInfo connectionRequestInfo) ! throws ResourceException { log.trace( --- 20,92 ---- import javax.resource.spi.ManagedConnectionMetaData; import javax.security.auth.Subject; + import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; + import javax.transaction.xa.Xid; + import net.sf.hibernate.HibernateException; import net.sf.hibernate.Session; ! import net.sf.hibernate.engine.SessionImplementor; ! import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** ! * Implementation of JCA Managed Connection. */ ! public class ManagedConnectionImpl implements ManagedConnection, XAResource { + /* + * @todo JCA 1.0, 5.10.1 + * A resource adapter is required to provide support for basic error + * logging and tracing by implementing the following methods: + * - ManagedConnectionFactory.set/getLogWriter + * - ManagedConnection.set/getLogWriter + */ private static final Log log = LogFactory.getLog(ManagedConnectionImpl.class); // the factory that created this managed connection ! private ManagedConnectionFactoryImpl mcf; ! // as per JCA 1.0 spec 5.6 when this is not null then logging has been ! // enabled by the application server and we log to this writer private PrintWriter logWriter; // registered listeners from the application server private final Collection listeners = new ArrayList(); ! /** ! * A set (actually a linked list) of JCASessionImpl handles associated with ! * this managed connection. First element of the list is the currect active ! * handle. ! * ! * <p>It is necessary to synchronize access to this list becase ! * <code>dissociateConnection</code> can be called asynchronously ! * from a context of a different transaction.</p> ! */ ! private final LinkedList handles = new LinkedList(); ! // a (logical handle to) database connection ! private Connection connection; ! // Hibernate session ! private SessionImplementor session; ! ! ManagedConnectionImpl(final ManagedConnectionFactoryImpl mcf) { ! log.trace("Constructor called"); this.mcf = mcf; } /** ! * Creates and returns a new Hibernate Session. * ! * Will throw a ResourceException if the session factory * fails to create a session */ ! public Object getConnection(final Subject subject, ! final ConnectionRequestInfo connectionRequestInfo) ! throws ResourceException ! { log.trace( *************** *** 101,122 **** + "]"); ! // maybe should check the credentials match up with the current connection? ! ! // create session from the session factory ! Session session = null; ! try { ! session = sessions.openSession(connection); ! } catch (Exception hbe) { ! log.error( ! "Error opening session with connection " + connection, ! hbe); ! throw new ResourceException(hbe.getMessage()); ! } ! JCASessionImpl jcaSession = new JCASessionImpl(session, this); ! // add the session handle to the collection of handles on this connection synchronized (handles) { ! handles.add(jcaSession); } --- 97,109 ---- + "]"); ! // make sure we have a session ! initializeSession(); ! final JCASessionImpl active = new JCASessionImpl(this); ! // add the session handle to the collection of handles ! // on this connection synchronized (handles) { ! handles.addFirst(active); } *************** *** 124,133 **** log.debug( "Added session handle - " ! + jcaSession + " to handles now at size " + handles.size()); } ! return jcaSession; } --- 111,160 ---- log.debug( "Added session handle - " ! + active + " to handles now at size " + handles.size()); } ! return active; ! } ! ! /** ! * Creates a session from the session factory ! */ ! private void initializeSession() throws ResourceException { ! // single threaded, no need to synchronize ! if (session == null) { ! initializeConnection(); ! session = (SessionImplementor) ! mcf.getSessionFactory().openSession(connection); ! } ! } ! ! /** ! * JDBC connection is lazy-inilialized during this call. A caller must ! * ensure proper thread context, i.e. context of original component ! * called into Hibernate session. ! */ ! private void initializeConnection() throws ResourceException { ! // single threaded, no need to synchronize ! if (connection == null) { ! try { ! connection = mcf.getDatasource().getConnection(); ! } catch (SQLException e) { ! final String message = "Cannot allocate database connection!"; ! throw newResourceException(message, e); ! } ! } ! } ! ! /** ! * Returns new ResourceException. ! */ ! private ResourceException newResourceException(final String message, ! final Exception e) ! { ! final ResourceException re = new ResourceException(message); ! re.setLinkedException(e); ! return re; } *************** *** 141,163 **** log.trace("destroy called on " + this); } - - if (connection == null) - throw new IllegalStateException("Resource cannot be destroyed because it is null"); - - try { - if (connection.isClosed()) - throw new IllegalStateException("Resource cannot be destroyed because it is already closed"); - - connection.close(); - connection = null; - } catch (SQLException ex) { - log.error("Error closing connection - " + connection, ex); - ResourceException re = - new ResourceException("Exception trying to close connection"); - re.setLinkedException(ex); - throw re; - } finally { - destroyed = true; - } } --- 168,171 ---- *************** *** 171,174 **** --- 179,185 ---- } + // JCA 1.0, 5.5.4 + // The cleanup is required to invalidate all connection + // handles created using this ManagedConnection instance. synchronized (handles) { for (Iterator i = handles.iterator(); i.hasNext();) { *************** *** 178,181 **** --- 189,218 ---- handles.clear(); } + + ResourceException re = null; + + try { + session.close(); + } catch (HibernateException e) { + final String message = + "Exception closing Hibernate session " + session; + re = newResourceException(message, e); + } finally { + session = null; + } + + try { + connection.close(); + } catch (SQLException e) { + final String message = + "Exception closing database connection " + connection; + re = newResourceException(message, e); + } finally { + connection = null; + } + + if (re != null) { + throw re; + } } *************** *** 183,219 **** * Associates the session handle with this managed connection */ ! public void associateConnection(Object handle) throws ResourceException { ! if (!(handle instanceof JCASessionImpl)) { throw new ResourceException( ! "Wrong kind of connection handle to associate " + handle); } ! ((JCASessionImpl) handle).setManagedConnection(this); synchronized (handles) { ! handles.add(handle); } } public void addConnectionEventListener(ConnectionEventListener listener) { ! synchronized (listeners) { ! listeners.add(listener); ! } } public void removeConnectionEventListener(ConnectionEventListener listener) { ! synchronized (listeners) { ! listeners.remove(listener); ! } } - /** - * NOT SUPPORTED - * @throws NotSupportedException - */ public XAResource getXAResource() throws ResourceException { ! throw new NotSupportedException("XA transaction not supported"); } public LocalTransaction getLocalTransaction() throws ResourceException { ! return new LocalTransactionImpl(this); } --- 220,266 ---- * Associates the session handle with this managed connection */ ! public void associateConnection(final Object object) ! throws ResourceException ! { ! if (!(object instanceof JCASessionImpl)) { throw new ResourceException( ! "Wrong kind of connection handle to associate " + object); } ! final JCASessionImpl handle = (JCASessionImpl) object; ! if (handle.getManagedConnextion() != this) { ! handle.getManagedConnextion().dissociateConnection(handle); ! handle.setManagedConnection(this); ! synchronized (handles) { ! handles.addFirst(handle); ! } ! } ! } ! ! private void dissociateConnection(final JCASessionImpl handle) { synchronized (handles) { ! handles.remove(handle); } } public void addConnectionEventListener(ConnectionEventListener listener) { ! listeners.add(listener); } public void removeConnectionEventListener(ConnectionEventListener listener) { ! listeners.remove(listener); } public XAResource getXAResource() throws ResourceException { ! return this; } public LocalTransaction getLocalTransaction() throws ResourceException { ! // JCA 1.0, section 6.1.10 ! // both LocalTransaction and XATransaction resource adapters ! // support local transactions ! // At the same time all transactions will enlist at least Hibernate ! // session and database connection, so support for local transactions ! // is really redundant. ! throw new NotSupportedException("LocalTransaction is not supported!"); } *************** *** 229,243 **** return logWriter; } - - public Properties getProps() { - return props; - } ! public void setProps(Properties props) { ! this.props = props; } - // package private level methods ManagedConnectionFactory getManagedConnectionFactory() { --- 276,323 ---- return logWriter; } ! // ! // XAResource implementation ! // ! ! // @todo ! // Currently, XAResource implementation does nothing. In the future, ! // in order to support JCS read-write cache it will be necessary ! // to implement prepare/commit/rollback protocol. ! ! // @todo JCA 6.6.2 ! // RM must ensure that TM invokes XAResource calls in the legal sequence, ! // and must return XAER_PROTO or other suitable error if the caller TM ! // violates the state tables (as defined in Chapter 6 of the XA ! // specification (refer [4]). ! public void commit(Xid arg0, boolean arg1) throws XAException { ! } ! public void end(Xid arg0, int arg1) throws XAException { ! } ! public void forget(Xid arg0) throws XAException { ! } ! public int getTransactionTimeout() throws XAException { ! return 0; ! } ! public boolean isSameRM(XAResource arg0) throws XAException { ! return false; ! } ! public int prepare(Xid arg0) throws XAException { ! return XAResource.XA_RDONLY; ! } ! public Xid[] recover(int arg0) throws XAException { ! return new Xid[0]; ! } ! public void rollback(Xid arg0) throws XAException { ! } ! public boolean setTransactionTimeout(int arg0) throws XAException { ! return false; ! } ! public void start(Xid arg0, int arg1) throws XAException { } + // // package private level methods + // ManagedConnectionFactory getManagedConnectionFactory() { *************** *** 249,253 **** // remove the handle from the collection safely synchronized (handles) { ! handles.remove(handle); } --- 329,333 ---- // remove the handle from the collection safely synchronized (handles) { ! handles.remove(handle); } *************** *** 260,267 **** } - Connection getConnection() { - return connection; - } - void sendEvent(final ConnectionEvent event) { int type = event.getId(); --- 340,343 ---- *************** *** 303,306 **** --- 379,407 ---- } } + } + + Session getSession(JCASessionImpl handle) { + // JCA 1.0, 5.5.4 + // Ensure that there is at most one connection handle associated + // actively with a ManagedConnection instance. [skiped] Any operations + // on the ManagedConnection from any previously created connection + // handles should result in an application level exception. + + // this might be pretty bad for performance, profile and find a + // better way if it is really bad + synchronized (handles) { + if (handles.get(0) == handle) { + return session; + } else { + final String message = "Inactive logical session handle called"; + // cannot throw HibernateException because not all Session + // methods throws it. This is incompatible with the spec! + throw new IllegalStateException(message); + } + } + } + + Connection getConnection() { + return connection; } } Index: ManagedConnectionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca/ManagedConnectionFactoryImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ManagedConnectionFactoryImpl.java 8 Mar 2003 09:53:35 -0000 1.2 --- ManagedConnectionFactoryImpl.java 1 May 2003 01:59:23 -0000 1.3 *************** *** 3,13 **** import java.io.PrintWriter; import java.io.Serializable; - import java.sql.Connection; - import java.sql.Driver; - import java.sql.DriverManager; import java.util.Iterator; import java.util.Properties; import java.util.Set; import javax.resource.NotSupportedException; import javax.resource.ResourceException; --- 3,13 ---- import java.io.PrintWriter; import java.io.Serializable; import java.util.Iterator; import java.util.Properties; import java.util.Set; + import javax.naming.Context; + import javax.naming.InitialContext; + import javax.naming.NamingException; import javax.resource.NotSupportedException; import javax.resource.ResourceException; *************** *** 16,23 **** import javax.resource.spi.ManagedConnection; import javax.resource.spi.ManagedConnectionFactory; - import javax.resource.spi.security.PasswordCredential; import javax.security.auth.Subject; import net.sf.hibernate.HibernateException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; --- 16,28 ---- import javax.resource.spi.ManagedConnection; import javax.resource.spi.ManagedConnectionFactory; import javax.security.auth.Subject; + import javax.sql.DataSource; import net.sf.hibernate.HibernateException; + import net.sf.hibernate.SessionFactory; + import net.sf.hibernate.cfg.Configuration; + import net.sf.hibernate.cfg.Environment; + import net.sf.hibernate.util.PropertiesHelper; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; *************** *** 31,72 **** implements ManagedConnectionFactory, Serializable { private static final Log log = LogFactory.getLog(ManagedConnectionFactoryImpl.class); ! private String connectionURL; ! private String driverClass; ! private String userName; ! private String password; ! private int transactionIsolation = -1; private String dialect; private String mapResources; - - private Properties connectionProperties = new Properties(); ! private PrintWriter out; ! private boolean driverLoaded; ! public ManagedConnectionFactoryImpl() { ! } /** * Creates a Hibernate SessionFactory for the container * ! * @throws ResourceException can't create Session Factory (thrown with linked exception) */ ! public Object createConnectionFactory(ConnectionManager cxManager) ! throws ResourceException { log("createConnectionFactory with connection manager - " + cxManager); Object obj = null; try { ! obj = new JCASessionFactoryImpl(this, cxManager, dialect, mapResources); } catch (HibernateException hbe) { ! log( ! "Got Hibernate exception when trying to create Connection Factory", ! hbe); ! ResourceException re = ! new ResourceException("Got Hibernate exception when trying to create Connection Factory"); re.setLinkedException(hbe); throw re; --- 36,98 ---- implements ManagedConnectionFactory, Serializable { + /* + * @todo JCA 1.0, 5.10.1 + * A resource adapter is required to provide support for basic error + * logging and tracing by implementing the following methods: + * - ManagedConnectionFactory.set/getLogWriter + * ManagedConnection.set/getLogWriter + */ private static final Log log = LogFactory.getLog(ManagedConnectionFactoryImpl.class); ! // ! // Resource adaptor configuration properties ! // ! ! /** SQL dialect */ private String dialect; + + /** O/R mappings */ private String mapResources; ! /** JNDI name of a datasource */ ! private String datasourceJndi; ! /** Hibernate properties */ ! private String properties; ! // ! // ! // ! private PrintWriter out; ! ! private DataSource datasource; ! ! private SessionFactory sessionFactory; /** * Creates a Hibernate SessionFactory for the container * ! * @throws ResourceException can't create Session Factory ! * (thrown with linked exception) */ ! public Object createConnectionFactory(final ConnectionManager cxManager) ! throws ResourceException ! { log("createConnectionFactory with connection manager - " + cxManager); + + // initialize datasource and session factory + initialize(); + Object obj = null; try { ! obj = new JCASessionFactoryImpl(this, cxManager); } catch (HibernateException hbe) { ! final String message = ! "Got Hibernate exception when trying to create " + ! "Connection Factory"; ! log(message, hbe); ! final ResourceException re = new ResourceException(message); re.setLinkedException(hbe); throw re; *************** *** 76,79 **** --- 102,159 ---- /** + * Initializes datasource (a.k.a JDBC connection factory) and Hibernate + * session factory. This method is synchonized, because a container does + * not have to serialize createConnectionFactory/createManagedConnection + * calls. + */ + private synchronized void initialize() throws ResourceException + { + // locate datasource + if (datasource == null) { + try { + Context ctx = new InitialContext(); + try { + datasource = (DataSource) ctx.lookup(datasourceJndi); + } finally { + ctx.close(); + } + } catch (NamingException e) { + final String message = + "Cannot locate DataSource " + datasourceJndi; + log(message, e); + final ResourceException re = new ResourceException(message); + re.setLinkedException(e); + throw re; + } + } + + // initialize session factory + if (sessionFactory == null) { + try { + final String delim = " ,\n\t\r\f"; + final Properties hibProperties = new Properties(); + // @todo load this.properties + hibProperties.setProperty(Environment.DIALECT, dialect); + + Configuration cfg = new Configuration().addProperties(hibProperties); + + // taken from HibernateService, maybe factor out for JCA 1.5 + String[] mappingFiles = PropertiesHelper.toStringArray(mapResources, delim); + for ( int i=0; i<mappingFiles.length; i++ ) { + cfg.addResource( mappingFiles[i], Thread.currentThread().getContextClassLoader() ); + } + sessionFactory = cfg.buildSessionFactory(); + } catch (HibernateException e) { + final String message = + "Cannot create Hibernate session factory"; + log(message, e); + final ResourceException re = new ResourceException(message); + re.setLinkedException(e); + throw re; + } + } + } + + /** * NOT SUPPORTED * *************** *** 81,139 **** */ public Object createConnectionFactory() throws ResourceException { ! throw new NotSupportedException("Resource Adapter does not support an un-managed environment"); } /** ! * Creates a ManagedConnection and physically a connection to the database ! * ! * Currently only uses username, password, driver class and URL ! * ! * Need to include mapping files, isolation level, dialect etc ! * ! * @throws ResourceException cannot get connection to database */ public ManagedConnection createManagedConnection( ! Subject subject, ! ConnectionRequestInfo info) ! throws ResourceException { ! log("createManagedConnection called"); ! try { ! ! // Also taken from JBoss JDBC JCA Impl ! Properties props = getConnectionProperties(subject, info); ! // Some friendly drivers (Oracle, you guessed right) modify the props you supply. ! // Since we use our copy to identify compatibility in matchManagedConnection, we need ! // a pristine copy for our own use. So give the friendly driver a copy. ! Properties copy = new Properties(); ! copy.putAll(props); ! ! String url = internalGetConnectionURL(); ! checkDriver(url); ! ! Connection con = DriverManager.getConnection(url, copy); ! ! // wait for the begin transaction to turn auto commit off? ! //con.setAutoCommit(false); ! ! return new ManagedConnectionImpl( ! this, ! userName, ! props, ! ((ConnectionRequestInfoImpl) info).getSessionFactory(), ! con); ! ! } catch (Exception ex) { ! log("Got exception when trying to create Managed Connection", ex); ! ResourceException re = ! new ResourceException("Got exception when trying to create Managed Connection"); ! re.setLinkedException(ex); ! throw re; ! } ! } ! public void setLogWriter(PrintWriter out) throws ResourceException { this.out = out; } --- 161,180 ---- */ public Object createConnectionFactory() throws ResourceException { ! throw new NotSupportedException("Resource Adapter does not support " + ! "an un-managed environment"); } /** ! * Creates a ManagedConnection */ public ManagedConnection createManagedConnection( ! final Subject subject, final ConnectionRequestInfo info) ! { log("createManagedConnection called"); ! return new ManagedConnectionImpl(this); } ! public void setLogWriter(final PrintWriter out) throws ResourceException { this.out = out; } *************** *** 143,251 **** } ! public ManagedConnection matchManagedConnections( ! Set mcs, ! Subject subject, ! ConnectionRequestInfo cri) ! throws ResourceException { ! Properties newProps = getConnectionProperties(subject, cri); for (Iterator i = mcs.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof ManagedConnectionImpl) { ! ManagedConnectionImpl mc = (ManagedConnectionImpl) o; ! if (mc.getProps().equals(newProps) /*&& mc.checkValid()*/ ! ) // JBoss method to check validity of connection by executing some SQL ! { ! return mc; ! } // end of if () ! ! } // end of if () ! } // end of for () return null; } /** ! * * @return hashcode computed according to recommendations in Effective Java. */ public int hashCode() { int result = 17; ! result = ! result * 37 ! + ((connectionURL == null) ? 0 : connectionURL.hashCode()); ! result = ! result * 37 + ((driverClass == null) ? 0 : driverClass.hashCode()); ! result = result * 37 + ((userName == null) ? 0 : userName.hashCode()); ! result = result * 37 + ((password == null) ? 0 : password.hashCode()); result = result * 37 + ((dialect == null) ? 0 : dialect.hashCode()); result = result * 37 + ((mapResources == null) ? 0 : mapResources.hashCode()); ! result = result * 37 + transactionIsolation; return result; } /** ! * ! * @param param1 <description> ! * @return <description> */ ! public boolean equals(Object other) { ! if (this == other) { return true; ! } // end of if () ! if (getClass() != other.getClass()) { ! return false; ! } // end of if () ! ManagedConnectionFactoryImpl otherMcf = ! (ManagedConnectionFactoryImpl) other; ! return this.connectionURL.equals(otherMcf.connectionURL) ! && this.driverClass.equals(otherMcf.driverClass) ! && ((this.mapResources == null) ! ? otherMcf.mapResources == null ! : this.mapResources.equals(otherMcf.mapResources)) ! && ((this.dialect == null) ! ? otherMcf.dialect == null ! : this.dialect.equals(otherMcf.dialect)) ! && ((this.userName == null) ! ? otherMcf.userName == null ! : this.userName.equals(otherMcf.userName)) ! && ((this.password == null) ! ? otherMcf.password == null ! : this.password.equals(otherMcf.password)) ! && this.transactionIsolation == otherMcf.transactionIsolation; ! ! } ! ! public String getDriverClass() { ! return driverClass; ! } ! ! public String getPassword() { ! return password; ! } ! ! public String getUserName() { ! return userName; ! } ! ! public void setDriverClass(String driverClass) { ! this.driverClass = driverClass; ! this.driverLoaded = false; ! } ! ! public void setPassword(String password) { ! this.password = password; } ! public void setUserName(String username) { ! this.userName = username; } ! public String getConnectionURL() { ! return connectionURL; } - public void setConnectionURL(String url) { - this.connectionURL = url; - } - public String getDialect() { return dialect; --- 184,251 ---- } ! public ManagedConnection matchManagedConnections(final Set mcs, ! final Subject subject, final ConnectionRequestInfo cri) ! throws ResourceException ! { for (Iterator i = mcs.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof ManagedConnectionImpl) { ! // all idle connections are identical ! return (ManagedConnectionImpl) o; ! } ! } return null; } /** ! * JCA 1.0, 5.5.3 ! * It is required that the ManagedConnectionFactory implementation class ! * extend the implementation of the hashCode and equals methods defined ! * in the java.lang.Object class. ! * * @return hashcode computed according to recommendations in Effective Java. */ public int hashCode() { int result = 17; ! result = result * 37 + ((datasourceJndi == null) ? 0 : datasourceJndi.hashCode()); result = result * 37 + ((dialect == null) ? 0 : dialect.hashCode()); result = result * 37 + ((mapResources == null) ? 0 : mapResources.hashCode()); ! result = result * 37 + ((properties == null) ? 0 : properties.hashCode()); return result; } /** ! * JCA 1.0, 5.5.3 ! * It is required that the ManagedConnectionFactory implementation class ! * extend the implementation of the hashCode and equals methods defined ! * in the java.lang.Object class. ! * ! * @return if object is equals based on a complete set of configuration ! * properties. */ ! public boolean equals(final Object object) { ! if (this == object) { return true; ! } ! boolean result = false; ! if (object instanceof ManagedConnectionFactoryImpl) { ! final ManagedConnectionFactoryImpl other = ! (ManagedConnectionFactoryImpl) object; ! result = equals(datasourceJndi, other.datasourceJndi) && ! equals(dialect, other.dialect) && ! equals(mapResources, other.mapResources) && ! equals(properties, other.properties); ! } ! return result; } ! public void setDatasourceJndi(String datasourceJndi) { ! this.datasourceJndi = datasourceJndi; } ! public String getDatasourceJndi() { ! return datasourceJndi; } public String getDialect() { return dialect; *************** *** 264,319 **** } ! public Properties getConnectionProperties() { ! return connectionProperties; } ! public void setConnectionProperties(Properties connectionProperties) { ! this.connectionProperties = connectionProperties; } ! public String getTransactionIsolation() { ! switch (this.transactionIsolation) { ! case Connection.TRANSACTION_NONE : ! return "TRANSACTION_NONE"; ! case Connection.TRANSACTION_READ_COMMITTED : ! return "TRANSACTION_READ_COMMITTED"; ! case Connection.TRANSACTION_READ_UNCOMMITTED : ! return "TRANSACTION_READ_UNCOMMITTED"; ! case Connection.TRANSACTION_REPEATABLE_READ : ! return "TRANSACTION_REPEATABLE_READ"; ! case Connection.TRANSACTION_SERIALIZABLE : ! return "TRANSACTION_SERIALIZABLE"; ! case -1 : ! return "DEFAULT"; ! default : ! return Integer.toString(transactionIsolation); ! } } ! public void setTransactionIsolation(String transactionIsolation) { ! if (transactionIsolation.equals("TRANSACTION_NONE")) { ! this.transactionIsolation = Connection.TRANSACTION_NONE; ! } else if (transactionIsolation.equals("TRANSACTION_READ_COMMITTED")) { ! this.transactionIsolation = Connection.TRANSACTION_READ_COMMITTED; ! } else if ( ! transactionIsolation.equals("TRANSACTION_READ_UNCOMMITTED")) { ! this.transactionIsolation = Connection.TRANSACTION_READ_UNCOMMITTED; ! } else if ( ! transactionIsolation.equals("TRANSACTION_REPEATABLE_READ")) { ! this.transactionIsolation = Connection.TRANSACTION_REPEATABLE_READ; ! } else if (transactionIsolation.equals("TRANSACTION_SERIALIZABLE")) { ! this.transactionIsolation = Connection.TRANSACTION_SERIALIZABLE; ! } else { ! try { ! this.transactionIsolation = ! Integer.parseInt(transactionIsolation); ! } catch (NumberFormatException nfe) { ! throw new IllegalArgumentException( ! "Setting Isolation level to unknown state: " ! + transactionIsolation); ! } ! } } private void log(String message) { log(message, null); --- 264,291 ---- } ! public String getHibernateProperties() { ! return properties; } ! public void setHibernateProperties(final String properties) { ! this.properties = properties; } ! // ! // Package private methods ! // ! ! DataSource getDatasource() { ! return datasource; } ! SessionFactory getSessionFactory() { ! return sessionFactory; } + // + // Private methods + // + private void log(String message) { log(message, null); *************** *** 321,325 **** private void log(String message, Throwable t) { - // log to provided output if set by app server // assumes to log error if an exception is provided --- 293,296 ---- *************** *** 335,474 **** log.info(message); } - - } - - // taken from JBoss JCA impl - - /** - * Check the driver for the given URL. If it is not registered already - * then register it. - * - * @param url The JDBC URL which we need a driver for. - */ - protected void checkDriver(final String url) throws ResourceException { - // don't bother if it is loaded already - if (driverLoaded) { - return; - } - log.debug("Checking driver for URL: " + url); - - if (driverClass == null) { - throw new ResourceException("No Driver class specified!"); - } - - // Check if the driver is already loaded, if not then try to load it - - if (isDriverLoadedForURL(url)) { - driverLoaded = true; - return; - } // end of if () - - try { - //try to load the class... this should register with DriverManager. - Class clazz = - Thread.currentThread().getContextClassLoader().loadClass( - driverClass); - if (isDriverLoadedForURL(url)) { - driverLoaded = true; - //return immediately, some drivers (Cloudscape) do not let you create an instance. - return; - } // end of if () - //We loaded the class, but either it didn't register - //and is not spec compliant, or is the wrong class. - Driver driver = (Driver) clazz.newInstance(); - DriverManager.registerDriver(driver); - if (isDriverLoadedForURL(url)) { - driverLoaded = true; - return; - } // end of if () - //We can even instantiate one, it must be the wrong class for the URL. - } catch (Exception e) { - ResourceException re = - new ResourceException( - "Failed to register driver for: " + driverClass); - re.setLinkedException(e); - throw re; - } - - throw new ResourceException( - "Apparently wrong driver class specified for URL: class: " - + driverClass - + ", url: " - + url); - } - - private boolean isDriverLoadedForURL(String url) { - try { - DriverManager.getDriver(url); - log.debug("Driver already registered for url: " + url); - return true; - } catch (Exception e) { - log.debug("Driver not yet registered for url: " + url); - return false; - } // end of try-catch - } - - protected String internalGetConnectionURL() { - return connectionURL; } /** ! * Gets full set of connection properties, i.e. whatever is provided ! * in config plus "user" and "password" from subject/cri. ! * ! * <p>Note that the set is used to match connections to datasources as well ! * as to create new managed connections. ! * ! * <p>In fact, we have a problem here. Theoretically, there is a possible ! * name collision between config properties and "user"/"password". */ ! protected Properties getConnectionProperties( ! Subject subject, ! ConnectionRequestInfo cri) ! throws ResourceException { ! if (cri != null && cri.getClass() != ConnectionRequestInfoImpl.class) { ! throw new ResourceException( ! "Wrong kind of ConnectionRequestInfo: " + cri.getClass()); ! } // end of if () ! ! Properties props = new Properties(); ! props.putAll(connectionProperties); ! if (subject != null) { ! for (Iterator i = subject.getPrivateCredentials().iterator(); ! i.hasNext(); ! ) { ! Object o = i.next(); ! if (o instanceof PasswordCredential ! && ((PasswordCredential) o) ! .getManagedConnectionFactory() ! .equals( ! this)) { ! PasswordCredential cred = (PasswordCredential) o; ! props.setProperty( ! "user", ! (cred.getUserName() == null) ? "" : cred.getUserName()); ! props.setProperty( ! "password", ! new String(cred.getPassword())); ! return props; ! } // end of if () ! } // end of for () ! throw new ResourceException("No matching credentials in Subject!"); ! } // end of if () ! ConnectionRequestInfoImpl lcri = (ConnectionRequestInfoImpl) cri; ! if (lcri != null) { ! props.setProperty( ! "user", ! (lcri.getUserName() == null) ? "" : lcri.getUserName()); ! props.setProperty( ! "password", ! (lcri.getPassword() == null) ? "" : lcri.getPassword()); ! return props; ! } // end of if () ! if (userName != null) { ! props.setProperty("user", userName); ! props.setProperty("password", (password == null) ? "" : password); } - return props; } } --- 306,323 ---- log.info(message); } } /** ! * Compares two objects assuming that <code>null</code> equals to ! * <code>null</code> */ ! private boolean equals(final Object o1, final Object o2) { ! if (o1 == o2) { ! return true; ! } else if (o1 != null) { ! return o1.equals(o2); ! } else { ! re... [truncated message content] |
From: <one...@us...> - 2003-04-30 07:46:49
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv16886/cirrus/hibernate Modified Files: Environment.java Log Message: version no Index: Environment.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Environment.java,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Environment.java 16 Apr 2003 06:30:49 -0000 1.85 --- Environment.java 30 Apr 2003 07:46:35 -0000 1.86 *************** *** 39,43 **** public final class Environment { ! private static final String VERSION = "1.2.4"; /** --- 39,43 ---- public final class Environment { ! private static final String VERSION = "1.2.5"; /** |
From: Manuel B. <Man...@gm...> - 2003-04-27 19:44:35
|
Here is everything: Code: try { Datastore ds = Hibernate.createDatastore() .storeFile("F:/java/ashop/ashop/mapping/ashop.hbm.xml"); SessionFactory sessions = ds.buildSessionFactory(); Session sess = sessions.openSession(); Item item = (Item) sess.load(Item.class, new Long(12)); System.out.println(item.toString()); } catch(MappingException ex) { System.out.println(ex); } catch(HibernateException ex) { System.out.println(ex); ex.printStackTrace(); } catch(java.sql.SQLException ex) { System.out.println(ex); } Mapping-files(shorten): <class name="ashop.elements.Category" table="kategorien"> <id column="id" name="id" type="long"> <generator class="sequence"/> </id> <property column="name" length="255" name="name" not-null="true" type="string"/> <set role="items" table="produkte"> <key column="kategorie"/> <one-to-many class="ashop.elements.Item"/> </set> </class> <class name="ashop.elements.Item" table="produkte"> <id column="ID" name="id" type="long"> <generator class="sequence"/> </id> <property column="artno" length="32" name="artno" type="string"/> <many-to-one name="category" column="kategorie" class="ashop.elements.Category"/> [...] </class> Consoleoutput: 27.04.2003 19:37:29 cirrus.hibernate.impl.DatastoreImpl storeFile INFO: Mapping file: F:/java/ashop/ashop/mapping/ashop.hbm.xml 27.04.2003 19:37:29 cirrus.hibernate.helpers.XMLHelper parseInputSource INFO: Parsing XML: F:/java/ashop/ashop/mapping/ashop.hbm.xml 27.04.2003 19:37:31 cirrus.hibernate.Environment <clinit> INFO: Hibernate 1.2.3 27.04.2003 19:37:31 cirrus.hibernate.Environment <clinit> INFO: loaded properties from resource hibernate.properties 27.04.2003 19:37:31 cirrus.hibernate.Environment <clinit> INFO: using java.io streams to persist binary types 27.04.2003 19:37:31 cirrus.hibernate.Environment <clinit> INFO: JVM proxy support: true 27.04.2003 19:37:31 cirrus.hibernate.sql.Dialect <init> INFO: Using dialect: cirrus.hibernate.sql.MySQLDialect 27.04.2003 19:37:31 cirrus.hibernate.connection.C3P0ConnectionProvider configure INFO: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/ashop 27.04.2003 19:37:31 cirrus.hibernate.connection.C3P0ConnectionProvider configure INFO: Connection properties: {user=root, password=55555} 27.04.2003 19:37:31 cirrus.hibernate.impl.SessionFactoryImpl <init> INFO: Use outer join fetching: true 27.04.2003 19:37:32 cirrus.hibernate.impl.SessionFactoryImpl <init> INFO: Use scrollable result sets: true 27.04.2003 19:37:32 cirrus.hibernate.impl.SessionFactoryImpl <init> INFO: echoing all SQL to stdout 27.04.2003 19:37:33 cirrus.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: no JDNI name configured 27.04.2003 19:37:33 cirrus.hibernate.impl.SessionFactoryImpl <init> INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0} 27.04.2003 19:37:33 cirrus.hibernate.impl.SessionFactoryImpl <init> INFO: Query language imports: cirrus.hibernate.test Hibernate: SELECT Categ1.id AS id0_, Categ1.ober as ober0_, Categ1.link as link0_, Categ1.activ as activ0_, Categ1.name as name0_, Categ1.beschreibung as beschreibung0_, Categ1.bild as bild0_, Categ1.showfor as showfor0_, Categ1.style as style0_, Categ1.custom as custom0_, Categ1.sort as sort0_, Item0.ID AS ID1_, Item0.artno as artno1_, Item0.kategorie as kategorie1_, Item0.activ as activ1_, Item0.name as name1_, Item0.kurzbeschreibung as kurzbeschreibung1_, Item0.beschreibung as beschreibung1_, Item0.keywords as keywords1_, Item0.preis as preis1_, Item0.mehrwertsteuer as mehrwertsteuer1_, Item0.link as link1_, Item0.variante as variante1_, Item0.gewicht as gewicht1_, Item0.groesse as groesse1_, Item0.laenge as laenge1_, Item0.hoehe as hoehe1_, Item0.breite as breite1_, Item0.farbe as farbe1_, Item0.style as style1_, Item0.vorrat as vorrat1_, Item0.bild as bild1_, Item0.thumb as thumb1_, Item0.partikel as partikel1_, Item0.rating as rating1_, Item0.custom as custom1_, Item0.letzte as letzte1_, Item0.sort as sort1_ FROM produkte Item0 LEFT OUTER JOIN kategorien Categ1 ON Item0.kategorie=Categ1.id WHERE Item0.ID = ? Hibernate: SELECT produ0.ID, Categ1.id AS id0_, Categ1.ober as ober0_, Categ1.link as link0_, Categ1.activ as activ0_, Categ1.name as name0_, Categ1.beschreibung as beschreibung0_, Categ1.bild as bild0_, Categ1.showfor as showfor0_, Categ1.style as style0_, Categ1.custom as custom0_, Categ1.sort as sort0_, produ0.ID AS ID1_, produ0.artno as artno1_, produ0.kategorie as kategorie1_, produ0.activ as activ1_, produ0.name as name1_, produ0.kurzbeschreibung as kurzbeschreibung1_, produ0.beschreibung as beschreibung1_, produ0.keywords as keywords1_, produ0.preis as preis1_, produ0.mehrwertsteuer as mehrwertsteuer1_, produ0.link as link1_, produ0.variante as variante1_, produ0.gewicht as gewicht1_, produ0.groesse as groesse1_, produ0.laenge as laenge1_, produ0.hoehe as hoehe1_, produ0.breite as breite1_, produ0.farbe as farbe1_, produ0.style as style1_, produ0.vorrat as vorrat1_, produ0.bild as bild1_, produ0.thumb as thumb1_, produ0.partikel as partikel1_, produ0.rating as rating1_, produ0.custom as custom1_, produ0.letzte as letzte1_, produ0.sort as sort1_ FROM produkte produ0 LEFT OUTER JOIN kategorien Categ1 ON produ0.kategorie=Categ1.id WHERE produ0.kategorie = ? Artikel mit der Nummer: 01007-00 geladen Artikel mit der Nummer: 01008-00 geladen Artikel mit der Nummer: 01012-00 geladen Artikel mit der Nummer: 01015-00 geladen Artikel mit der Nummer: 01010-00 geladen java.lang.StackOverflowError at java.util.HashMap.newKeyIterator(HashMap.java:810) at java.util.HashMap$KeySet.iterator(HashMap.java:842) at java.util.HashSet.iterator(HashSet.java:148) at java.util.AbstractCollection.toString(AbstractCollection.java:447) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Item.toString(Item.java:331) at java.lang.String.valueOf(String.java:2173) at java.util.AbstractCollection.toString(AbstractCollection.java:451) at cirrus.hibernate.collections.Set.toString(Set.java:214) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:348) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:245) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:292) at org.apache.commons.lang.builder.ToStringBuilder.reflectionToString(ToStringB uilder.java:231) at ashop.elements.Category.toString(Category.java:161) at java.lang.String.valueOf(String.java:2173) at java.lang.StringBuffer.append(StringBuffer.java:369) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.jav a:337) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.j ava:322) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:224) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java: 326) at org.apache.commons.lang.builder.ToStringBuilder.reflectio... [truncated message content] |
From: <one...@us...> - 2003-04-27 07:04:33
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv23093 Modified Files: List.java Map.java Set.java Log Message: fixed signature of hashCode()s Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/List.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** List.java 25 Apr 2003 03:40:31 -0000 1.12 --- List.java 27 Apr 2003 07:04:30 -0000 1.13 *************** *** 409,413 **** } ! public int hashCode(Object other) { read(); return list.hashCode(); --- 409,413 ---- } ! public int hashCode() { read(); return list.hashCode(); Index: Map.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Map.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Map.java 25 Apr 2003 03:40:31 -0000 1.12 --- Map.java 27 Apr 2003 07:04:30 -0000 1.13 *************** *** 375,379 **** } ! public int hashCode(Object other) { read(); return map.hashCode(); --- 375,379 ---- } ! public int hashCode() { read(); return map.hashCode(); Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Set.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Set.java 25 Apr 2003 03:40:31 -0000 1.12 --- Set.java 27 Apr 2003 07:04:30 -0000 1.13 *************** *** 381,385 **** } ! public int hashCode(Object other) { read(); return set.hashCode(); --- 381,385 ---- } ! public int hashCode() { read(); return set.hashCode(); |
From: <tu...@us...> - 2003-04-26 21:22:44
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv13979/src Modified Files: examples.xml Log Message: Added parent/child relationship example Index: examples.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/examples.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** examples.xml 3 Mar 2003 01:07:03 -0000 1.5 --- examples.xml 26 Apr 2003 21:22:41 -0000 1.6 *************** *** 345,349 **** </sect1> ! </chapter> --- 345,711 ---- </sect1> ! ! <sect1 id="examples-s3"> ! <title>Parent/Child Relationship</title> ! ! <para> ! One of the very first things that new users try to do with Hibernate ! is to model a parent/child type relationship. There are two different approaches to ! this. For various reasons the most convenient approach, especially for new users, ! is to model both <literal>Parent</literal> and <literal>Child</literal> as entity ! classes with a <literal><one-to-many></literal> association from ! <literal>Parent</literal> to <literal>Child</literal>. The alternative approach is ! to declare the <literal>Child</literal> as a <literal><composite-element></literal>. ! Now, it turns out that default semantics of a one to many association (in Hibernate) ! are much less close to the usual semantics of a parent/child relationship than those of ! a composite element mapping. We will explain how to use a bidirectional one-to-many ! association with cascades to model a parent/child relationship efficiently and elegantly. ! Its not at all difficult! ! </para> ! ! <sect2 id="examples-s3-1"> ! <title>Collections</title> ! ! <para> ! Hibernate collections are considered to be a logical part of their owning entity ! (in our example, the <literal>Parent</literal>); never of the contained entities ! (<literal>Child</literal> objects). This is a critical distinction! It has the ! following consequences: ! </para> ! ! <itemizedlist> ! <listitem> ! <para> ! When we remove/add an object from/to a collection, the version number ! of the collection owner is incremented. ! </para> ! </listitem> ! <listitem> ! <para> ! If an object that was removed from a collection is an instance of a ! value type (eg, a composite element without an independent lifecycle), that ! object will cease to be persistent and its state will be completely removed ! from the database. Likewise, adding a value type instance to the collection ! will cause its state to be immediately persistent. ! </para> ! </listitem> ! <listitem> ! <para> ! On the other hand, if an <emphasis>entity</emphasis> (a first class object with ! its own lifecycle) is removed from a collection (a one-to-many or ! many-to-many association), it will <emphasis>not</emphasis> be deleted, by default. ! This behaviour is completely consistent - a change to the internal state of another ! entity should not cause the associated entity to vanish! Likewise, adding an entity ! to a collection does not cause that entity to become persistent, by default. ! </para> ! </listitem> ! </itemizedlist> ! ! <para> ! Instead, the default behaviour is that adding an entity to a collection merely creates ! a link between the two entities, while removing it removes the link. This is very ! appropriate for all sorts of cases. Where it is not appropriate <emphasis>at all</emphasis> ! is the case of a parent/child relationship, where the life of the child is bound to the ! lifecycle of the parent even if the child is not a dependent component but a first class ! object. ! </para> ! ! </sect2> ! ! <sect2 id="examples-s3-2"> ! <title>Bidirectional one-to-many Associations</title> ! ! <para> ! Suppose we start with a simple <literal><one-to-many></literal> association from ! <literal>Parent</literal> to <literal>Child</literal>. ! </para> ! ! <programlisting><![CDATA[<set name="children"> ! <key column="parent_id"/> ! <one-to-many class="Child"/> ! </set>]]></programlisting> ! ! <para> ! If we were to execute the following code ! </para> ! ! <programlisting><![CDATA[Parent p = .....; ! Child c = new Child(); ! p.getChildren().add(c); ! session.save(c); ! session.flush();]]></programlisting> ! ! <para> ! Hibernate would issue two SQL statements: ! </para> ! ! <itemizedlist spacing="compact"> ! <listitem> ! <para> ! an <literal>INSERT</literal> to create the record for <literal>c</literal> ! </para> ! </listitem> ! <listitem> ! <para> ! an <literal>UPDATE</literal> to create the link from <literal>p</literal> ! to <literal>c</literal> ! </para> ! </listitem> ! </itemizedlist> ! ! <para> ! This is not only inefficient, but also violates any <literal>NOT NULL</literal> ! constraint on the parent_id column. ! </para> ! ! <para> ! The underlying cause is that the link (the foreign key constraint upon ! <literal>parent_id</literal>) from <literal>p</literal> to <literal>c</literal> ! is not considered part of the state of the <literal>Child</literal> object and ! is therefore not created in the <literal>INSERT</literal>. So the solution is to ! make the link part of the <literal>Child</literal> mapping (bidirectional). ! </para> ! ! <programlisting><![CDATA[<many-to-one name="parent" column="parent_id" not-null="true"/>]]></programlisting> ! ! <para> ! (We also need to add the <literal>parent</literal> property to the Child class.) ! </para> ! ! <para> ! Now that the <literal>Child</literal> entity is managing the state of the link, we ! tell the collection not to update the link. The attribute in the mapping used for ! that purpose is <literal>inverse</literal>. ! </para> ! ! <programlisting><![CDATA[<set name="children" inverse="true"> ! <key column="parent_id"/> ! <one-to-many class="Child"/> ! </set>]]></programlisting> ! ! <para> ! The following code would be used to add a new <literal>Child</literal>: ! </para> ! ! <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid); ! Child c = new Child(); ! c.setParent(p); ! p.getChildren().add(c); ! session.save(c); ! session.flush();]]></programlisting> ! ! <para> ! And now, only one SQL <literal>INSERT</literal> would be issued! ! </para> ! ! <para> ! To tighten things up a bit, we could create an <literal>addChild()</literal> ! method of <literal>Parent</literal>: ! </para> ! ! <programlisting><![CDATA[public void addChild(Child c) { ! c.setParent(this); ! children.add(c); ! }]]></programlisting> ! ! <para> ! Now, the code to add a <literal>Child</literal> looks like this: ! </para> ! ! <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid); ! Child c = new Child(); ! p.addChild(c); ! session.save(c); ! session.flush();]]></programlisting> ! ! </sect2> ! ! <sect2 id="examples-s3-3"> ! <title>Cascades</title> ! ! <para> ! The explicit call to <literal>save()</literal> is still annoying. We will ! address this by using cascades. ! </para> ! ! <programlisting><![CDATA[<set name="children" inverse="true" cascade="all"> ! <key column="parent_id"/> ! <one-to-many class="Child"/> ! </set>]]></programlisting> ! ! <para> ! This simplifies the code above to ! </para> ! ! <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid); ! Child c = new Child(); ! p.addChild(c); ! session.flush();]]></programlisting> ! ! <para> ! Similarly, we don't need to iterate over the children when saving or deleting ! a <literal>Parent</literal>. The following removes <literal>p</literal> and ! all its children from the database when using cascading operations: ! </para> ! ! <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid); ! session.delete(p); ! session.flush();]]></programlisting> ! ! <para> ! However, this code ! </para> ! ! <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid); ! Child c = (Child) p.getChildren().iterator().next(); ! p.getChildren().remove(c); ! c.setParent(null); ! session.flush();]]></programlisting> ! ! <para> ! will <emphasis>not</emphasis> remove <literal>c</literal> from the database; ! it will ony remove the link to <literal>p</literal> (and cause a <literal>NOT NULL</literal> ! constraint violation, in this case). You need to explicitly <literal>delete()</literal> ! the Child since, by design, Hibernate does not have a garbage collector! Use ! </para> ! ! <programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid); ! Child c = (Child) p.getChildren().iterator().next(); ! p.getChildren().remove(c); ! session.delete(c); ! session.flush();]]></programlisting> ! ! <para> ! <emphasis>Note:</emphasis> even though the collection mapping specifies ! <literal>inverse="true"</literal>, cascades are still processed by iterating the ! collection elements. So if you require that an object be saved, deleted or ! updated by cascade, you must add it to the collection. It is not enough to simply ! call <literal>setParent()</literal> on the <literal>Child</literal> object. ! </para> ! ! </sect2> ! ! <sect2 id="examples-s3-4"> ! <title>Using cascading <literal>update()</literal></title> ! ! <para> ! Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</literal>, ! made some changes in a UI action and wish to persist these changes in a new ! <literal>Session</literal> (by calling <literal>update()</literal>). The ! <literal>Parent</literal> will contain a collection of children and, since cascading ! update is enabled, Hibernate needs to know which children are newly instantiated and ! which represent existing rows in the database. Lets assume that both ! <literal>Parent</literal> and <literal>Child</literal> have (synthetic) identifier ! properties of type <literal>java.lang.Long</literal>. Hibernate will use the identifier ! property value to determine which of the children are new. ! </para> ! ! <para> ! The <literal>unsaved-value</literal> attribute is used to specify the identifier ! value of a newly instantiated instance. In Hibernate2, <literal>unsaved-value</literal> ! defaults to <literal>"null"</literal>, which is perfect for a <literal>Long</literal> ! identifier type. ! </para> ! ! <para> ! The following code will update <literal>parent</literal> and <literal>child</literal> ! and insert <literal>newChild</literal>: ! </para> ! ! <programlisting><![CDATA[//parent and child were both loaded in a previous session ! parent.addChild(child); ! Child newChild = new Child(); ! parent.addChild(newChild); ! session.update(parent); ! session.flush();]]></programlisting> ! ! <para> ! Well, thats all very well for the case of a generated identifier, but what about ! assigned identifiers and composite identifiers? This is more difficult, since ! <literal>unsaved-value</literal> can't distinguish between a newly instantiated ! object (with an identifier assigned by the user) and an object loaded in a ! previous session. In these cases, you will probably need to give Hibernate ! a hint; either ! </para> ! ! <itemizedlist spacing="compact"> ! <listitem> ! <para> ! set <literal>unsaved-value="none"</literal> and explicitly ! <literal>save()</literal> newly instantiated children ! </para> ! </listitem> ! <listitem> ! <para> ! set <literal>unsaved-value="any"</literal> and explicitly ! <literal>update()</literal> loaded children ! </para> ! </listitem> ! </itemizedlist> ! ! <para> ! before calling <literal>update(parent)</literal>. The first option is probably more ! sensible and so that is the default <literal>unsaved-value</literal> in Hibernate2. ! </para> ! ! <para> ! There is one further possibility. There is a new Interceptor method named ! <literal>isUnsaved()</literal> which lets the application implement its own ! strategy for distinguishing newly instantiated objects. For example, you could ! define a base class for your persistent classes ! </para> ! ! <programlisting><![CDATA[public class Persistent implements Lifecycle { ! private boolean _saved = false; ! public boolean onSave(Session s) { ! _saved=true; ! return NO_VETO; ! } ! public void onLoad(Session s, Serializable id) { ! _saved=true; ! } ! ...... ! public boolean isSaved() { ! return _saved; ! } ! }]]</programlisting> ! ! <para> ! And implement <literal>isUnsaved()</literal> ! </para> ! ! <programlisting><![CDATA[public Boolean isUnsaved(Object entity) { ! if (entity instanceof Persistent) { ! return new Boolean( !( (Persistent) entity ).isSaved() ); ! } ! else { ! return null; ! } ! }]]></programlisting> ! ! </sect2> ! ! <sect2 id="examples-s3-5"> ! <title>Conclusion</title> ! ! <para> ! There is quite a bit to digest here and it might look confusing first time ! around. However, in practice, it all works out quite nicely. Most Hibernate ! applications use the parent/child pattern in many places. ! </para> ! ! <para> ! We mentioned an alternative in the first paragraph of this example. None of ! these issues exist in the case of <literal><composite-element></literal> ! mappings, which have <emphasis>exactly</emphasis> the semantics of a parent/child ! relationship. Unfortunately there are some severe limitations to composite element ! classes (at least in the current implementation). Composite elements may not own ! collections and may not be used in queries. Furthermore, they do not have surrogate ! primary keys, which is usually a much more flexible relational model. ! </para> ! </sect2> ! ! </sect1> ! </chapter> |
From: <tu...@us...> - 2003-04-26 20:42:08
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv30978/src Modified Files: session_configuration.xml Log Message: Fixed intendation and added JNDI tip Index: session_configuration.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/session_configuration.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** session_configuration.xml 22 Apr 2003 11:11:36 -0000 1.10 --- session_configuration.xml 26 Apr 2003 20:42:04 -0000 1.11 *************** *** 508,515 **** </tgroup> </table> ! ! <sect2 id="session-configuration-s5-1"> ! <title>SQL Dialects</title> ! <para> You should always set the <literal>hibernate.dialect</literal> property to the correct --- 508,515 ---- </tgroup> </table> ! ! <sect2 id="session-configuration-s5-1"> ! <title>SQL Dialects</title> ! <para> You should always set the <literal>hibernate.dialect</literal> property to the correct *************** *** 590,596 **** </sect2> ! <sect2 id="session-configuration-s5-2"> ! <title>Outer Join Fetching</title> ! <para> If your database supports ANSI or Oracle style outerjoins, <emphasis>outer join --- 590,596 ---- </sect2> ! <sect2 id="session-configuration-s5-2"> ! <title>Outer Join Fetching</title> ! <para> If your database supports ANSI or Oracle style outerjoins, <emphasis>outer join *************** *** 601,635 **** The fetched graph ends at leaf objects, objects with proxies or where circular references occur. This behaviour may be disabled for a particular association ! by setting <literal>outer-join="false"</literal>. </para> ! ! </sect2> ! ! <sect2 id="session-configuration-s5-3"> ! <title>Binary Streams</title> ! <para> Oracle limits the size of <literal>byte</literal> arrays that may be passed to/from its JDBC driver. If you wish to use large instances of ! <literal>binary</literal> or <literal>serializable</literal> type, you should enable <literal>hibernate.jdbc.use_streams_for_binary</literal>. <emphasis>This is a JVM-level setting only.</emphasis> </para> ! </sect2> - <sect2 id="session-configuration-s5-4"> - <title>SQL Logging to Console</title> - <para> ! <literal>hibernate.show_sql</literal> forces Hibernate to write SQL statements to the console. This is provided as an easy alternative to enabling logging. </para> ! </sect2> - <sect2 id="session-configuration-s5-5"> - <title>Custom <literal>ConnectionProvider</literal></title> - <para> ! You may define your own plugin strategy for obtaining JDBC connections by implementing the interface <literal>net.sf.hibernate.connection.ConnectionProvider</literal>. --- 601,634 ---- The fetched graph ends at leaf objects, objects with proxies or where circular references occur. This behaviour may be disabled for a particular association ! by setting <literal>outer-join="false"</literal> in the XML mapping metadata. </para> ! </sect2> ! ! <sect2 id="session-configuration-s5-3"> ! <title>Binary Streams</title> ! <para> Oracle limits the size of <literal>byte</literal> arrays that may be passed to/from its JDBC driver. If you wish to use large instances of ! <literal>binary</literal> or <literal>serializable</literal> type, you should enable <literal>hibernate.jdbc.use_streams_for_binary</literal>. <emphasis>This is a JVM-level setting only.</emphasis> </para> ! </sect2> ! ! <sect2 id="session-configuration-s5-4"> ! <title>SQL Logging to Console</title> <para> ! <literal>hibernate.show_sql</literal> forces Hibernate to write SQL statements to the console. This is provided as an easy alternative to enabling logging. </para> ! </sect2> ! ! <sect2 id="session-configuration-s5-5"> ! <title>Custom <literal>ConnectionProvider</literal></title> <para> ! You may define your own plugin strategy for obtaining JDBC connections by implementing the interface <literal>net.sf.hibernate.connection.ConnectionProvider</literal>. *************** *** 637,752 **** <literal>hibernate.connection.provider_class</literal>. </para> ! </sect2> ! <sect2 id="session-configuration-s5-6"> ! <title>Transaction Strategy</title> ! ! <para> ! If you wish to use the Hibernate <literal>Transaction</literal> API, you must ! specify a factory class for <literal>Transaction</literal> instances by ! setting the property <literal>hibernate.transaction.factory_class</literal>. ! There are two standard (built-in) choices: ! <variablelist spacing="compact"> ! <varlistentry> ! <term><literal>net.sf.hibernate.transaction.JDBCTransactionFactory</literal></term> ! <listitem> ! <para>delegates to database (JDBC) transactions</para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term><literal>net.sf.hibernate.transaction.JTATransactionFactory</literal></term> ! <listitem> ! <para>delegates to JTA (if an existing transaction is underway, the <literal>Session</literal> ! performs its work in that context, otherwise a new transaction is started)</para> ! </listitem> ! </varlistentry> ! </variablelist> ! </para> ! <para> ! You may also define your own transaction strategies (for a CORBA transaction service, ! for example). ! </para> ! <para> ! If you wish to use JVM-level caching of mutable data in a JTA environment, you must specify ! a strategy for obtaining the JTA <literal>TransactionManager</literal>. ! </para> ! <table frame="all"> ! <title>JTA TransactionManagers</title> ! <tgroup cols="2"> ! <colspec colwidth="2.5*"/> ! <colspec colwidth="1*"/> ! <thead> ! <row> ! <entry>Transaction Factory</entry> ! <entry align="center">Application Server</entry> ! </row> ! </thead> ! <tbody> ! <row> ! <entry><literal>net.sf.hibernate.transaction.JBossTransactionManagerLookup</literal></entry> ! <entry align="center">JBoss</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry> ! <entry align="center">Weblogic</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry> ! <entry align="center">WebSphere</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.OrionTransactionManagerLookup</literal></entry> ! <entry align="center">Orion</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.ResinTransactionManagerLookup</literal></entry> ! <entry align="center">Resin</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry> ! <entry align="center">JRun4</entry> ! </row> ! </tbody> ! </tgroup> ! </table> </sect2> - - <sect2 id="session-configuration-s5-7"> - <title>JNDI-bound <literal>SessionFactory</literal></title> - - - <para> - If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify - a name (eg. <literal>hibernate/session_factory</literal>) as using the property - <literal>hibernate.session_factory_name</literal>. Then EJBs, for example, may obtain the - <literal>SessionFactory</literal> using a JNDI lookup. Hibernate will use - <literal>hibernate.jndi.url</literal>, <literal>hibernate.jndi.class</literal> to instantiate - an initial context. - </para> - </sect2> - - <sect2 id="session-configuration-s5-8"> - <title>Query Language Substitution</title> - - <para> - You may define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>. - For example: - </para> - <programlisting>hibernate.query.substitutions true=1, false=0</programlisting> ! <para> ! would cause the tokens <literal>true</literal> and <literal>false</literal> to be translated to ! integer literals in the generated SQL. ! </para> ! ! <programlisting>hibernate.query.substitutions toLowercase=LOWER</programlisting> ! ! <para> ! would allow you to rename the SQL <literal>LOWER</literal> function. ! </para> ! </sect2> --- 636,761 ---- <literal>hibernate.connection.provider_class</literal>. </para> ! </sect2> ! <sect2 id="session-configuration-s5-6"> ! <title>Transaction Strategy</title> ! <para> ! If you wish to use the Hibernate <literal>Transaction</literal> API, you must ! specify a factory class for <literal>Transaction</literal> instances by ! setting the property <literal>hibernate.transaction.factory_class</literal>. ! There are two standard (built-in) choices: ! <variablelist spacing="compact"> ! <varlistentry> ! <term><literal>net.sf.hibernate.transaction.JDBCTransactionFactory</literal></term> ! <listitem> ! <para>delegates to database (JDBC) transactions</para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term><literal>net.sf.hibernate.transaction.JTATransactionFactory</literal></term> ! <listitem> ! <para>delegates to JTA (if an existing transaction is underway, the <literal>Session</literal> ! performs its work in that context, otherwise a new transaction is started)</para> ! </listitem> ! </varlistentry> ! </variablelist> ! </para> ! <para> ! You may also define your own transaction strategies (for a CORBA transaction service, ! for example). ! </para> ! <para> ! If you wish to use JVM-level caching of mutable data in a JTA environment, you must specify ! a strategy for obtaining the JTA <literal>TransactionManager</literal>. ! </para> ! ! <table frame="all"> ! <title>JTA TransactionManagers</title> ! <tgroup cols="2"> ! <colspec colwidth="2.5*"/> ! <colspec colwidth="1*"/> ! <thead> ! <row> ! <entry>Transaction Factory</entry> ! <entry align="center">Application Server</entry> ! </row> ! </thead> ! <tbody> ! <row> ! <entry><literal>net.sf.hibernate.transaction.JBossTransactionManagerLookup</literal></entry> ! <entry align="center">JBoss</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry> ! <entry align="center">Weblogic</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry> ! <entry align="center">WebSphere</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.OrionTransactionManagerLookup</literal></entry> ! <entry align="center">Orion</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.ResinTransactionManagerLookup</literal></entry> ! <entry align="center">Resin</entry> ! </row> ! <row> ! <entry><literal>net.sf.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry> ! <entry align="center">JRun4</entry> ! </row> ! </tbody> ! </tgroup> ! </table> </sect2> ! <sect2 id="session-configuration-s5-7"> ! <title>JNDI-bound <literal>SessionFactory</literal></title> ! ! <para> ! If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify ! a name (eg. <literal>java:comp/env/hibernate/SessionFactory</literal>) as using the property ! <literal>hibernate.session_factory_name</literal>. ! </para> ! ! <para> ! If the attribute or property is omitted, the <literal>SessionFactory</literal> will not be ! bound to JNDI, this is especially useful in environments with a read-only JNDI default ! implementation, ie. Tomcat. ! </para> ! ! <para> ! If you use JNDI, EJBs or any other utility class may obtain the <literal>SessionFactory</literal> ! using a JNDI lookup. Hibernate will use <literal>hibernate.jndi.url</literal>, ! <literal>hibernate.jndi.class</literal> to instantiate an initial context. ! </para> ! ! </sect2> ! ! <sect2 id="session-configuration-s5-8"> ! <title>Query Language Substitution</title> ! ! <para> ! You may define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>. ! For example: ! </para> ! ! <programlisting>hibernate.query.substitutions true=1, false=0</programlisting> ! ! <para> ! would cause the tokens <literal>true</literal> and <literal>false</literal> to be translated to ! integer literals in the generated SQL. ! </para> ! ! <programlisting>hibernate.query.substitutions toLowercase=LOWER</programlisting> ! ! <para> ! would allow you to rename the SQL <literal>LOWER</literal> function. ! </para> ! </sect2> *************** *** 772,776 **** <!-- a SessionFactory instance listed as /jndi/name --> ! <session-factory name="/jndi/name"> <!-- properties --> --- 781,785 ---- <!-- a SessionFactory instance listed as /jndi/name --> ! <session-factory name="java:comp/env/hibernate/SessionFactory"> <!-- properties --> |
From: <tu...@us...> - 2003-04-26 19:36:29
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv6667/src Modified Files: advanced_or_mapping.xml query_language.xml Log Message: Integrated more FAQs Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** advanced_or_mapping.xml 26 Apr 2003 01:42:29 -0000 1.18 --- advanced_or_mapping.xml 26 Apr 2003 19:36:25 -0000 1.19 *************** *** 491,494 **** --- 491,501 ---- </itemizedlist> + <para> + You can use the <literal>filter()</literal> method of the Hibernate Session API to + get the size of a collection without initializing it: + </para> + + <programlisting><![CDATA[( (Integer) s.createFilter( collection, "select count(*)" ).iterate().next() ).intValue()]]></programlisting> + </sect2> Index: query_language.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/query_language.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** query_language.xml 21 Apr 2003 06:23:42 -0000 1.11 --- query_language.xml 26 Apr 2003 19:36:25 -0000 1.12 *************** *** 670,674 **** </sect1> ! <sect1 id="query-language-s10"> <title>Examples</title> --- 670,674 ---- </sect1> ! <sect1 id="query-language-s10"> <title>Examples</title> *************** *** 792,797 **** order by account.type.sortOrder, account.accountNumber, payment.dueDate]]></programlisting> ! </sect1> ! </chapter> --- 792,866 ---- order by account.type.sortOrder, account.accountNumber, payment.dueDate]]></programlisting> ! </sect1> ! ! <sect1 id="query-language-s11"> ! <title>Tips & Tricks</title> ! ! <para> ! You can count the number of query results without actually returning them: ! </para> ! ! <programlisting><![CDATA[( (Integer) session.iterate("select count(*) from ....").next() ).intValue()]]></programlisting> ! ! <para> ! To order a result by the size of a collection, use the following query ! for a one-to-many or many-to-many association: ! </para> ! ! <programlisting><![CDATA[select user ! from user in class eg.User, ! msg in user.messages.elements ! group by user ! order by count(msg)]]></programlisting> ! ! <para> ! If your database supports subselects, you can place a condition upon selection ! size in the where clause of your query: ! </para> ! ! <programlisting><![CDATA[from user in class eg.User ! where user.messages.size >= 1]]></programlisting> ! ! <para> ! If your database doesn't support subselects or you're dealing with a one-to-many ! or a many-to-many association, use the following query: ! </para> ! ! <programlisting><![CDATA[select user ! from user in class eg.User, ! msg in user.messages.elements ! group by user ! having count(msg) >= 1]]></programlisting> ! ! <para> ! As this solution can't return a <literal>User</literal> with zero messages ! because of the implicit inner join, se following form is also useful: ! </para> ! ! <programlisting><![CDATA[select user ! from eg.User as user ! left join user.messages.elements as msg ! group by user ! having count(msg) = 0]]></programlisting> ! ! <para> ! Properties of a JavaBean can be bound to named query parameters: ! </para> ! ! <programlisting><![CDATA[Query q = s.createQuery("from foo in class Foo where foo.name=:name and foo.size=:size"); ! q.setProperties(fooBean); // fooBean has getName() and getSize() ! List foos = q.list();]]></programlisting> ! ! <para> ! Collections are pageable when using the query API: ! </para> ! ! <programlisting><![CDATA[Query q = s.createFilter( collection, "" ); // the trivial filter ! q.setMaxResults(PAGE_SIZE); ! q.setFirstResult(PAGE_SIZE * pageNumber); ! List page = q.list();]]></programlisting> ! ! </sect1> ! </chapter> |
From: <one...@us...> - 2003-04-26 06:14:19
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv9968 Modified Files: SessionFactoryImpl.java Log Message: fixed threading bug Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** SessionFactoryImpl.java 10 Apr 2003 09:53:40 -0000 1.65 --- SessionFactoryImpl.java 26 Apr 2003 06:14:16 -0000 1.66 *************** *** 281,285 **** } ! private transient final ReferenceMap queryCache = new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT); public QueryTranslator getQuery(String query) throws QueryException, MappingException { --- 281,287 ---- } ! private transient final Map queryCache = Collections.synchronizedMap( ! new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT) ! ); public QueryTranslator getQuery(String query) throws QueryException, MappingException { |
From: <one...@us...> - 2003-04-26 06:09:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv8736/persister Modified Files: AbstractEntityPersister.java Log Message: fixed problem for XML parsers which don't use DTD default values Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** AbstractEntityPersister.java 25 Apr 2003 03:40:35 -0000 1.23 --- AbstractEntityPersister.java 26 Apr 2003 06:09:11 -0000 1.24 *************** *** 497,508 **** String unsavedValue = model.getIdentifier().getNullValue(); ! if ( unsavedValue==null || "any".equals(unsavedValue) ) { ! unsavedIdentifierValue=Cascades.SAVE_ANY; } else if ( "none".equals(unsavedValue) ) { unsavedIdentifierValue=Cascades.SAVE_NONE; } ! else if ( "null".equals(unsavedValue) ) { ! unsavedIdentifierValue=Cascades.SAVE_NULL; } else { --- 497,508 ---- String unsavedValue = model.getIdentifier().getNullValue(); ! if ( unsavedValue==null || "null".equals(unsavedValue) ) { ! unsavedIdentifierValue=Cascades.SAVE_NULL; } else if ( "none".equals(unsavedValue) ) { unsavedIdentifierValue=Cascades.SAVE_NONE; } ! else if ( "any".equals(unsavedValue) ) { ! unsavedIdentifierValue=Cascades.SAVE_ANY; } else { |
From: <one...@us...> - 2003-04-26 06:09:13
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv8736/cfg Modified Files: Binder.java Log Message: fixed problem for XML parsers which don't use DTD default values Index: Binder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Binder.java 25 Apr 2003 05:56:32 -0000 1.15 --- Binder.java 26 Apr 2003 06:09:11 -0000 1.16 *************** *** 997,1001 **** Attribute dcNode = hmNode.attribute("default-cascade"); model.setDefaultCascade( (dcNode==null) ? "none" : dcNode.getValue() ); ! model.setAutoImport( "true".equals( hmNode.attributeValue("auto-import") ) ); Iterator nodes = hmNode.elementIterator("class"); --- 997,1002 ---- Attribute dcNode = hmNode.attribute("default-cascade"); model.setDefaultCascade( (dcNode==null) ? "none" : dcNode.getValue() ); ! Attribute aiNode = hmNode.attribute("auto-import"); ! model.setAutoImport( (aiNode==null) ? true : "true".equals( aiNode.getValue() ) ); Iterator nodes = hmNode.elementIterator("class"); |
From: <one...@us...> - 2003-04-26 03:58:33
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv8589/doc/reference/src Modified Files: basic_or_mapping.xml best_practices.xml manipulating_data.xml transactions.xml Log Message: doco fixes Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** basic_or_mapping.xml 26 Apr 2003 01:42:29 -0000 1.17 --- basic_or_mapping.xml 26 Apr 2003 03:58:29 -0000 1.18 *************** *** 527,532 **** <programlisting><![CDATA[<composite-id name="propertyName" ! class="ClassName" ! unsaved-value="any|none|null"> <key-property name="propertyName" type="typename" column="column_name"/> --- 527,531 ---- <programlisting><![CDATA[<composite-id name="propertyName" ! class="ClassName"> <key-property name="propertyName" type="typename" column="column_name"/> *************** *** 573,585 **** <literal>class</literal> (optional - defaults to the property type determined by reflection): The component class used as a composite identifier (see next section). - </para> - </listitem> - <listitem> - <para> - <literal>unsaved-value</literal> (optional - defaults to <literal>any</literal>): - An identifier property value that indicates that an instance is newly instantiated - (unsaved), distinguishing it from transient instances that were saved or loaded - in a previous session. Once again, this attibute applies only when a component - class is used to represent the composite identifier. </para> </listitem> --- 572,575 ---- Index: best_practices.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/best_practices.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** best_practices.xml 23 Feb 2003 13:53:24 -0000 1.2 --- best_practices.xml 26 Apr 2003 03:58:29 -0000 1.3 *************** *** 40,44 **** <listitem> <para> - Deploy the mappings along with the classes they map. </para> --- 40,43 ---- *************** *** 58,63 **** <listitem> <para> ! As in JDBC, always replace non-constant ! values by "?". Never use string manipulation to bind a non-constant value in a query! </para> </listitem> --- 57,63 ---- <listitem> <para> ! As in JDBC, always replace non-constant values by "?". Never use string manipulation to ! bind a non-constant value in a query! Even better, consider using named parameters in ! queries. </para> </listitem> *************** *** 77,83 **** <listitem> <para> ! Suppose you have a Java type, say ! from some library, that needs to be persisted but doesn't provide the accessors ! needed to map it as a component. You should consider implementing <literal>net.sf.hibernate.UserType</literal>. This approach frees the application code from implementing transformations to / from a Hibernate type. --- 77,82 ---- <listitem> <para> ! Suppose you have a Java type, say from some library, that needs to be persisted but doesn't ! provide the accessors needed to map it as a component. You should consider implementing <literal>net.sf.hibernate.UserType</literal>. This approach frees the application code from implementing transformations to / from a Hibernate type. *************** *** 135,139 **** This is more of a necessary paractice than a "best" practice. When an exception occurs, roll back the <literal>Transaction</literal> and close the <literal>Session</literal>. If you don't, Hibernate ! can't guarantee that in-memory state accurately represents persistent state </para> </listitem> --- 134,164 ---- This is more of a necessary paractice than a "best" practice. When an exception occurs, roll back the <literal>Transaction</literal> and close the <literal>Session</literal>. If you don't, Hibernate ! can't guarantee that in-memory state accurately represents persistent state. As a special case of this, ! do not use <literal>Session.load()</literal> to determine if an instance with the given identifier ! exists on the database; use <literal>find()</literal> instead. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Prefer lazy fetching for associations.</term> ! <listitem> ! <para> ! Use eager (outer-join) fetching sparingly. Use proxies and/or lazy collections for most associations ! to classes that are not cached at the JVM-level. For associations to cached classes, where there is ! a high probability of a cache hit, explicitly disable eager fetching using ! <literal>outer-join="false"</literal>. When an outer-join fetch is appropriate to a particular use ! case, use a query with a <literal>left join</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Consider abstracting your business logic from Hibernate.</term> ! <listitem> ! <para> ! Hide (Hibernate) data-access code behind an interface. Combine the <emphasis>DAO</emphasis> and ! <emphasis>Thread Local Session</emphasis> patterns. You can even have some classes persisted by ! handcoded JDBC, associated to Hibernate via a <literal>UserType</literal>. (This advice is ! intended for "sufficiently large" applications; it is not appropriate for an application with ! five tables!) </para> </listitem> Index: manipulating_data.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/manipulating_data.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** manipulating_data.xml 22 Apr 2003 20:28:14 -0000 1.8 --- manipulating_data.xml 26 Apr 2003 03:58:29 -0000 1.9 *************** *** 460,464 **** <listitem> <para> ! <literal>any</literal> - always save (this is the default!) </para> </listitem> --- 460,464 ---- <listitem> <para> ! <literal>any</literal> - always save </para> </listitem> *************** *** 470,474 **** <listitem> <para> ! <literal>null</literal> - save when identifier is null </para> </listitem> --- 470,474 ---- <listitem> <para> ! <literal>null</literal> - save when identifier is null (this is the default) </para> </listitem> Index: transactions.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/transactions.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** transactions.xml 18 Mar 2003 09:55:27 -0000 1.5 --- transactions.xml 26 Apr 2003 03:58:29 -0000 1.6 *************** *** 258,262 **** while ( iter.hasNext() ) { Foo foo = (Foo) iter.next(); ! s.lock(foo, LockMode.SHARED); //check that foo isn't stale bar.getFooTable().put( foo.getName(), foo ); } --- 258,262 ---- while ( iter.hasNext() ) { Foo foo = (Foo) iter.next(); ! s.lock(foo, LockMode.READ); //check that foo isn't stale bar.getFooTable().put( foo.getName(), foo ); } |
From: <one...@us...> - 2003-04-26 03:58:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv8589/src/net/sf/hibernate Modified Files: Session.java Log Message: doco fixes Index: Session.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Session.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Session.java 25 Apr 2003 03:40:30 -0000 1.17 --- Session.java 26 Apr 2003 03:58:29 -0000 1.18 *************** *** 197,201 **** /** ! * Return the persistent instance of the given entity class with the given identifier. * * @param theClass a persistent class --- 197,205 ---- /** ! * Return the persistent instance of the given entity class with the given identifier.<br> ! * <br> ! * You should not use this method to determine if an instance exists (use <tt>find()</tt> ! * instead). Use this only to retrieve an instance that you assume exists, where non-existence ! * would be an actual error. * * @param theClass a persistent class *************** *** 207,211 **** /** ! * Read the persistent state associated with the given identifier into the given transient instance. * * @param object an "empty" instance of the persistent class --- 211,216 ---- /** ! * Read the persistent state associated with the given identifier into the given transient ! * instance. * * @param object an "empty" instance of the persistent class |
From: <one...@us...> - 2003-04-26 03:58:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv8589/src/net/sf/hibernate/cfg Modified Files: Environment.java Log Message: doco fixes Index: Environment.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Environment.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Environment.java 25 Apr 2003 03:40:30 -0000 1.10 --- Environment.java 26 Apr 2003 03:58:29 -0000 1.11 *************** *** 37,41 **** * The <tt>SessionFactory</tt> is controlled by the following properties. * Properties may be either be <tt>System</tt> properties, properties ! * defined in a resource named <tt>/hibernate.properties</tt> an instance of * <tt>java.util.Properties</tt> passed to * <tt>Configuration.buildSessionFactory()</tt><br> --- 37,41 ---- * The <tt>SessionFactory</tt> is controlled by the following properties. * Properties may be either be <tt>System</tt> properties, properties ! * defined in a resource named <tt>/hibernate.properties</tt> or an instance of * <tt>java.util.Properties</tt> passed to * <tt>Configuration.buildSessionFactory()</tt><br> |
From: <tu...@us...> - 2003-04-26 01:42:33
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv4472/src Modified Files: advanced_or_mapping.xml basic_or_mapping.xml Log Message: Integrated some more FAQ items Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** advanced_or_mapping.xml 19 Apr 2003 03:34:34 -0000 1.17 --- advanced_or_mapping.xml 26 Apr 2003 01:42:29 -0000 1.18 *************** *** 200,204 **** </calloutlist> </programlistingco> ! </sect2> --- 200,235 ---- </calloutlist> </programlistingco> ! ! <para> ! The mapping of a List or array requires a seperate table column holding the array or List index ! (the <literal>i</literal> in <literal>foo[i]</literal>). If your relational model doesn't have ! an index column, e.g. if you're working with legacy data, use an unordered <literal>Set</literal> ! instead. This seems to put people off who assume that <literal>List</literal> should just be a ! more convenient way of accessing an unordered collection. Hibernate collections strictly obey ! the actual semantics attached to the <literal>Set</literal>, <literal>List</literal> and ! <literal>Map</literal> interfaces. <literal>List</literal> elements don't just spontaneously ! rearrange themselves. ! </para> ! ! <para> ! On the other hand, people who planned to use the <literal>List</literal> to emulate "bag"-style ! semantics have a legitimate grievance here. Fortunately you can map a <literal>List</literal> ! or <literal>Collection</literal> with bag semantics. ! </para> ! ! <para> ! A bag is an unordered, unindexed collection which can contain the same element multiple times. ! The Java collections framework lacks a <literal>Bag</literal> interface (though you can emulat ! it with a <literal>List</literal>). Hibernate lets you map properties of type <literal>List</literal> ! or <literal>Collection</literal> with the <literal><bag></literal> element. Note that bag ! semantics are not really part of the <literal>Collection</literal> contract and they actually ! conflict with the semantics of <literal>List</literal>. ! </para> ! ! <para> ! Large Hibernate bags are inefficient and should be avoided, Hibernate can't create, delete or ! update rows individually with such a mapping. ! </para> ! </sect2> *************** *** 293,297 **** <listitem> <para> ! No null values may be contained in a map or set </para> </listitem> --- 324,328 ---- <listitem> <para> ! No null values may be contained in a map, set or list </para> </listitem> *************** *** 333,336 **** --- 364,376 ---- The <literal>one-to-many</literal> tag does not need to declare any columns. </para> + + <para> + If the <literal>key</literal> column in the database is declared as + <literal>NOT NULL</literal>, Hibernate may cause constraint violations. + To prevent this, you must use a bidirectional association with the many-end + (the set, bag, list or map) marked as <literal>inverse="true"</literal> to + ensure the correct order of updates in the database. + </para> + </sect2> *************** *** 378,382 **** <para> ! Declare a lazy collection using the optional <literal>lazy</literal> attribute </para> --- 418,422 ---- <para> ! Declare a lazy collection using the optional <literal>lazy</literal> attribute: </para> *************** *** 386,389 **** --- 426,494 ---- </set>]]></programlisting> + <para> + As we already mentioned, the <literal>Session</literal> must not be committed + nor closed when a collection is initialized. This can be confusing for new + Hibernate users, as a first approach would abstract the data access logic from + the upper layers of the application. With this kind of architecture, an + uninitialized collection may be returned from a method of the data access + class while the <literal>Session</literal> is already committed and closed in + that returning method. They are several ways to deal with this issue: + </para> + + <itemizedlist> + <listitem> + <para> + In a web-based application, a Servlet Filter can be used to finally + close the <literal>Session</literal> when the rendering of the + View has completed. Of course, it can be difficult to ensure that + the <literal>Session</literal> is rolled backed if an exception + occours during the rendering of the View. The Servlet Filter has to + know about the <literal>Session</literal> for this approach: A + <literal>ThreadLocal</literal> variable can be used to hold the + current <literal>Session</literal> of a thread during execution. + That way, a Servlet Filter can open (or <literal>reconnect()</literal>) + a <literal>Session</literal> when a new HTTP request arrives, place + the <literal>Session</literal> in a <literal>ThreadLocal</literal> + variable and lateron close (or <literal>disconnect()</literal> and store + it in the users <literal>HttpSession</literal>) the + <literal>Session</literal> when the request has been successfuly executed. + The data access classes obtain the current <literal>Session</literal> + from the <literal>ThreadLocal</literal> variable. This setup is best + wrapped with helper and utility classes (ie. a class for Hibernate + <literal>Session</literal> management). + </para> + </listitem> + <listitem> + <para> + If the application is not web-based and has no distinct rendering of + a View, the usage of a <literal>ThreadLocal</literal> can be adapted + as required (replacing the Servlet Filter with another request/response + based filter class). + </para> + </listitem> + <listitem> + <para> + The data access class can provide methods that start and end + units of work like <literal>dao.beginUOW()</literal> and + <literal>dao.endUOW()</literal> which would internally open and close + a <literal>Session</literal>. This is no different from re-using a single + JDBC <literal>Connection</literal> during multiple method calls on a + standard data access object in an non-managed environment with explicit + transaction management by the user. + </para> + </listitem> + <listitem> + <para> + Hibernate can initialize collections itself with a call to + <literal>Hibernate.initialize(Object object)</literal>. Keep in mind + though, that the <literal>Session</literal> which was used to lazily + load the collection must still be open when it is initialized. This method + is primarily used in a data access class to initialize a known subset of + collections before the whole object containing that collections is returned + to the caller and the <literal>Session</literal> is closed. + </para> + </listitem> + </itemizedlist> + </sect2> *************** *** 415,418 **** --- 520,532 ---- <literal>java.util.TreeMap</literal>. </para> + + <para> + Another approach is to use the <literal>order-by</literal> attribute of either + <literal>set</literal>, <literal>map</literal> or <literal>list</literal> mappings. + This solution is only available with JDK 1.4 or higher. Please note that a collection + can be be sorted arbitrary at runtime by a the <literal>filter()</literal> method of the + Hibernate Session API. + </para> + </sect2> *************** *** 444,448 **** <listitem> <para> ! Set valued at one end, single-valued at the other </para> </listitem> --- 558,562 ---- <listitem> <para> ! Set/Bag/List/Map valued at one end, single-valued at the other </para> </listitem> *************** *** 452,456 **** <listitem> <para> ! Set/bag valued at both ends </para> </listitem> --- 566,570 ---- <listitem> <para> ! Set/Bag/List/Map valued at both ends </para> </listitem> *************** *** 506,509 **** --- 620,643 ---- <many-to-one name="parent" class="eg.Parent" column="parent_id"/> </class>]]></programlisting> + + <para> + Mapping one end of an association with <literal>inverse="true"</literal> doesn't + affect the cascading of operations. The <literal>inverse="true"</literal> marks + one end of an association as "bidirectional". Of course, this happens with the + mapping the assocation itself, ie. if the many-end is mapped as a + <literal>set</literal>. But Hibernate can optimize the semantics of an update of + the bidirectional association when marked with the <literal>inverse="true"</literal> + attribute, ie. the ordering of <literal>UPDATE</literal> statements executed on + the database. The multi-valued end of a one-to-many association has always to be + marked with <literal>inverse="true"</literal> if the association is bidirectional. + </para> + + <para> + The <literal>cascade="all"</literal> simply marks the cascading of calls to + <literal>save()</literal>, <literal>update()</literal>, <literal>delete()</literal>, + etc. It doesn't interact in any way with the <literal>inverse="true"</literal> mapping, + both concepts are orthogonal. + </para> + </sect2> Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** basic_or_mapping.xml 24 Apr 2003 09:23:12 -0000 1.16 --- basic_or_mapping.xml 26 Apr 2003 01:42:29 -0000 1.17 *************** *** 211,215 **** It is perfectly acceptable for the named persistent class to be an interface. You would then declare implementing classes of that interface using the <literal><subclass></literal> ! element. </para> --- 211,216 ---- It is perfectly acceptable for the named persistent class to be an interface. You would then declare implementing classes of that interface using the <literal><subclass></literal> ! element. You may persist any <emphasis>static</emphasis> inner class. You should specify the ! class name using the standard form ie. <literal>eg.Foo$Bar</literal>. </para> *************** *** 834,837 **** --- 835,856 ---- <literal>Hibernate.TIMESTAMP</literal>, or to specify a custom type.) </para> + + <para> + If you want to customize the database type of the generated SQL DDL (when using + the Hibernate toolset to generate the schema), you can set the appropriate type + with the <literal>sql-type</literal> attribute of the + <literal><column></literal> element (in addition to the <literal>column</literal> + name attribute of the <literal>property</literal>). This element has several other + attributes related to automatic schema generation: + </para> + + <programlisting><![CDATA[<property name="amount" type="big_decimal"> + <column sql-type="NUMERIC(11, 2)" not-null="true"/> + </property> + + <property name="socialsecuritynumber" type="string"> + <column sql-type="CHAR" length="9" not-null="true" unique="true"/> + </property>]]></programlisting> + </sect2> *************** *** 1588,1592 **** </sect1> - </chapter> --- 1607,1610 ---- |
From: <one...@us...> - 2003-04-25 05:56:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv28546/hibernate/impl Modified Files: BatcherImpl.java CacheEntry.java CriteriaImpl.java FilterImpl.java MessageHelper.java NonBatchingBatcher.java QueryImpl.java ScrollableResultsImpl.java SessionFactoryImpl.java SessionImpl.java Log Message: *enabled composite key collection filters *added some JavaDoc Index: BatcherImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/BatcherImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BatcherImpl.java 5 Jan 2003 02:11:21 -0000 1.3 --- BatcherImpl.java 25 Apr 2003 05:56:33 -0000 1.4 *************** *** 17,20 **** --- 17,22 ---- /** * Manages prepared statements and batching. Class exists to enforce seperation of concerns. + * + * @author Gavin King */ public abstract class BatcherImpl implements Batcher { Index: CacheEntry.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/CacheEntry.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CacheEntry.java 6 Apr 2003 10:11:09 -0000 1.5 --- CacheEntry.java 25 Apr 2003 05:56:33 -0000 1.6 *************** *** 13,16 **** --- 13,18 ---- /** * A cached instance of a persistent class + * + * @author Gavin King */ public final class CacheEntry implements Serializable { Index: CriteriaImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/CriteriaImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CriteriaImpl.java 9 Mar 2003 04:04:08 -0000 1.2 --- CriteriaImpl.java 25 Apr 2003 05:56:33 -0000 1.3 *************** *** 11,14 **** --- 11,18 ---- import net.sf.hibernate.expression.Order; + /** + * Implementation of the <tt>Criteria</tt> interface + * @author Gavin King + */ public class CriteriaImpl implements Criteria { Index: FilterImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/FilterImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FilterImpl.java 25 Apr 2003 03:40:33 -0000 1.8 --- FilterImpl.java 25 Apr 2003 05:56:33 -0000 1.9 *************** *** 14,17 **** --- 14,18 ---- /** * implementation of the <tt>Query</tt> interface for collection filters + * @author Gavin King */ public class FilterImpl extends QueryImpl { Index: MessageHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/MessageHelper.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MessageHelper.java 21 Apr 2003 06:28:18 -0000 1.1 --- MessageHelper.java 25 Apr 2003 05:56:33 -0000 1.2 *************** *** 8,15 **** /** ! * helper methods for rendering log messages and exception ! * messages */ public final class MessageHelper { public static String infoString(Class clazz, Serializable id) { --- 8,18 ---- /** ! * Helper methods for rendering log messages and exception ! * messages. ! * @author Max Andersen, Gavin King */ public final class MessageHelper { + + //TODO: use these methods in lost more places! public static String infoString(Class clazz, Serializable id) { Index: NonBatchingBatcher.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/NonBatchingBatcher.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NonBatchingBatcher.java 5 Jan 2003 02:11:21 -0000 1.3 --- NonBatchingBatcher.java 25 Apr 2003 05:56:33 -0000 1.4 *************** *** 10,13 **** --- 10,15 ---- /** * An implementation of the <tt>Batcher</tt> interface that does no batching + * + * @author Gavin King */ public class NonBatchingBatcher extends BatcherImpl { Index: QueryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/QueryImpl.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** QueryImpl.java 25 Apr 2003 03:40:34 -0000 1.16 --- QueryImpl.java 25 Apr 2003 05:56:33 -0000 1.17 *************** *** 36,39 **** --- 36,40 ---- * for "ordinary" HQL queries (not collection filters) * @see FilterImpl + * @author Gavin King */ public class QueryImpl implements Query { Index: ScrollableResultsImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/ScrollableResultsImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScrollableResultsImpl.java 14 Jan 2003 13:42:12 -0000 1.5 --- ScrollableResultsImpl.java 25 Apr 2003 05:56:33 -0000 1.6 *************** *** 19,22 **** --- 19,26 ---- import net.sf.hibernate.type.Type; + /** + * Implementation of the <tt>ScrollableResults</tt> interface + * @author Gavin King + */ public class ScrollableResultsImpl implements ScrollableResults { Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SessionFactoryImpl.java 19 Apr 2003 03:26:07 -0000 1.19 --- SessionFactoryImpl.java 25 Apr 2003 05:56:33 -0000 1.20 *************** *** 78,86 **** /** ! * Concrete implementation of a SessionFactory ! * ! * IMMUTABLE (except for caches) */ - public final class SessionFactoryImpl implements SessionFactory, SessionFactoryImplementor { --- 78,104 ---- /** ! * Concrete implementation of the <tt>SessionFactory</tt> interface. Has the following ! * responsibilites ! * <ul> ! * <li>caches configuration settings (immutably) ! * <li>caches "compiled" mappings ie. <tt>ClassPersister</tt>s and ! * <tt>CollectionPersister</tt>s (immutable) ! * <li>caches "compiled" queries (memory sensitive cache) ! * <li>manages <tt>PreparedStatement</tt>s ! * <li> delegates JDBC <tt>Connection</tt> management to the <tt>ConnectionProvider</tt> ! * <li>factory for instances of <tt>SessionImpl</tt> ! * </ul> ! * This class must appear immutable to clients, even if it does all kinds of caching ! * and pooling under the covers. It is crucial that the class is not only thread ! * safe, but also highly concurrent. Synchronization must be used extremely sparingly. ! * ! * @see net.sf.hibernate.ps.PreparedStatementCache ! * @see net.sf.hibernate.connection.ConnectionProvider ! * @see Session ! * @see net.sf.hibernate.hql.QueryTranslator ! * @see net.sf.hibernate.persister.ClassPersister ! * @see net.sf.hibernate.collection.CollectionPersister ! * @author Gavin King */ public final class SessionFactoryImpl implements SessionFactory, SessionFactoryImplementor { *************** *** 658,661 **** --- 676,684 ---- } + /** + * Return the names of all persistent (mapped) classes that extend or implement the + * given class or interface, accounting for implicit/explicit polymorphism settings + * and excluding mapped subclasses/joined-subclasses of other classes in the result. + */ public String[] getImplementors(Class clazz) { //if ( classPersisters.containsKey(clazz) ) return null; *************** *** 703,706 **** --- 726,736 ---- } + /** + * <ol> + * <li>close the prepared statement cache (and all prepared statements) + * <li>close the JDBC connection + * <li>remove the JNDI binding + * </ol> + */ public void close() throws HibernateException { Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** SessionImpl.java 21 Apr 2003 06:34:46 -0000 1.38 --- SessionImpl.java 25 Apr 2003 05:56:33 -0000 1.39 *************** *** 84,87 **** --- 84,89 ---- * * NOT THREADSAFE + * + * @author Gavin King */ public final class SessionImpl implements SessionImplementor { |
From: <one...@us...> - 2003-04-25 05:56:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv28546/hibernate/loader Modified Files: Loader.java Log Message: *enabled composite key collection filters *added some JavaDoc Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Loader.java 25 Apr 2003 03:40:34 -0000 1.19 --- Loader.java 25 Apr 2003 05:56:33 -0000 1.20 *************** *** 407,411 **** } ! if (namedParams!=null) bindNamedParameters(st, namedParams, values.length, session); } --- 407,411 ---- } ! if (namedParams!=null) bindNamedParameters(st, namedParams, col, session); } |
From: <one...@us...> - 2003-04-25 05:56:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv28546/hibernate/cfg Modified Files: Binder.java Log Message: *enabled composite key collection filters *added some JavaDoc Index: Binder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Binder.java 11 Apr 2003 07:15:52 -0000 1.14 --- Binder.java 25 Apr 2003 05:56:32 -0000 1.15 *************** *** 782,786 **** // UNSAVED-VALUE Attribute nullValueNode = node.attribute("unsaved-value"); ! if (nullValueNode!=null) model.setNullValue( nullValueNode.getValue() ); } --- 782,791 ---- // UNSAVED-VALUE Attribute nullValueNode = node.attribute("unsaved-value"); ! if (nullValueNode!=null) { ! model.setNullValue( nullValueNode.getValue() ); ! } ! else { ! model.setNullValue("null"); ! } } |
From: <one...@us...> - 2003-04-25 05:56:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv28546/hibernate/test Modified Files: FumTest.java Log Message: *enabled composite key collection filters *added some JavaDoc Index: FumTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FumTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FumTest.java 15 Feb 2003 08:00:55 -0000 1.2 --- FumTest.java 25 Apr 2003 05:56:33 -0000 1.3 *************** *** 49,52 **** --- 49,53 ---- } assertTrue(i==2); + s.delete( s.load(Fum.class, (Serializable) list.get(0) ) ); s.delete( s.load(Fum.class, (Serializable) list.get(1) ) ); *************** *** 215,218 **** --- 216,227 ---- } assertTrue( j==8, "iterate on composite key" ); + + fum = (Fum) s.load( Fum.class, fum.getId() ); + s.filter( fum.getQuxArray(), "where this.foo is null" ); + s.filter( fum.getQuxArray(), "where this.foo.id = ?", "fooid", Hibernate.STRING ); + Query f = s.createFilter( fum.getQuxArray(), "where this.foo.id = :fooId" ); + f.setString("fooId", "abc"); + assertFalse( f.iterate().hasNext() ); + iter = s.iterate("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); int i = 0; |
From: <one...@us...> - 2003-04-25 05:56:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv28546/hibernate/hql Modified Files: QueryTranslator.java Log Message: *enabled composite key collection filters *added some JavaDoc Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** QueryTranslator.java 8 Apr 2003 09:49:27 -0000 1.24 --- QueryTranslator.java 25 Apr 2003 05:56:33 -0000 1.25 *************** *** 355,359 **** void addNamedParameter(String name) { if (superQuery!=null) superQuery.addNamedParameter(name); ! Integer loc = new Integer(++parameterCount); Object o = namedParameters.get(name); if (o==null) { --- 355,359 ---- void addNamedParameter(String name) { if (superQuery!=null) superQuery.addNamedParameter(name); ! Integer loc = new Integer(parameterCount++); Object o = namedParameters.get(name); if (o==null) { *************** *** 655,659 **** CollectionPersister persister = getCollectionPersister(collectionRole); String[] keyColumnNames = persister.getKeyColumnNames(); ! if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole); JoinFragment join = createJoinFragment(); --- 655,659 ---- CollectionPersister persister = getCollectionPersister(collectionRole); String[] keyColumnNames = persister.getKeyColumnNames(); ! //if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole); JoinFragment join = createJoinFragment(); |