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-04-04 13:58:22
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv11567/test Modified Files: FooBarTest.java Log Message: fixed problem with proxy.getId() for an interface proxy Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooBarTest.java,v retrieving revision 1.242 retrieving revision 1.243 diff -C2 -d -r1.242 -r1.243 *** FooBarTest.java 13 Mar 2003 02:52:20 -0000 1.242 --- FooBarTest.java 4 Apr 2003 13:58:16 -0000 1.243 *************** *** 6,9 **** --- 6,11 ---- import cirrus.hibernate.connection.ConnectionProvider; import cirrus.hibernate.connection.DriverManagerConnectionProvider; + import cirrus.hibernate.proxy.HibernateProxy; + import cirrus.hibernate.proxy.HibernateProxyHelper; import cirrus.hibernate.sql.DB2Dialect; import cirrus.hibernate.sql.HSQLDialect; *************** *** 569,572 **** --- 571,578 ---- q = (Qux) s.load(Qux.class, q.getKey() ); b = (BarProxy) s.load( Foo.class, b.getKey() ); + b.getKey(); + assertTrue( HibernateProxyHelper.getLazyInitializer( (HibernateProxy) b ).isUninitialized() ); + b.getBarString(); + assertFalse( HibernateProxyHelper.getLazyInitializer( (HibernateProxy) b ).isUninitialized() ); BarProxy b2 = (BarProxy) s.load( Bar.class, new String( b.getKey() ) ); Qux q2 = (Qux) s.load( Qux.class, q.getKey() ); |
From: <one...@us...> - 2003-04-04 13:58:19
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv11567/persister Modified Files: AbstractEntityPersister.java Log Message: fixed problem with proxy.getId() for an interface proxy Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** AbstractEntityPersister.java 28 Jan 2003 10:22:26 -0000 1.21 --- AbstractEntityPersister.java 4 Apr 2003 13:58:12 -0000 1.22 *************** *** 491,495 **** Method proxyGetter = identifierGetter.getMethod(); try { ! proxyGetter = ReflectHelper.getGetter( model.getProxyInterface(), identifierPropertyName ).getMethod(); } catch (Exception e) {} --- 491,499 ---- Method proxyGetter = identifierGetter.getMethod(); try { ! proxyGetter = ReflectHelper.getGetter( ! //model.getProxyInterface(), //for old dynamic proxies ! mappedClass, ! identifierPropertyName ! ).getMethod(); } catch (Exception e) {} |
From: <one...@us...> - 2003-04-04 13:52:05
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv7478/hibernate/test Modified Files: Baz.hbm.xml FooBarTest.java FooComponent.java Log Message: added NonstrictReadWriteCache fixed problem with proxy.getId() for an interface proxy Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Baz.hbm.xml 2 Apr 2003 13:10:37 -0000 1.15 --- Baz.hbm.xml 4 Apr 2003 13:51:59 -0000 1.16 *************** *** 69,72 **** --- 69,73 ---- </map> <map name="fooComponentToFoo"> + <jcs-cache usage="read-write"/> <key> <column name="baz_id" length="16"/> Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** FooBarTest.java 3 Apr 2003 12:34:29 -0000 1.46 --- FooBarTest.java 4 Apr 2003 13:51:59 -0000 1.47 *************** *** 687,690 **** --- 687,691 ---- map = new HashMap(); map.put( new FooComponent("name", 123, null, null), bar ); + map.put( new FooComponent("nameName", 12, null, null), bar ); baz.setFooComponentToFoo(map); map = new HashMap(); *************** *** 696,699 **** --- 697,708 ---- s = sessions.openSession(); baz = (Baz) s.find("select baz from baz in class net.sf.hibernate.test.Baz order by baz").get(0); + Session s2 = sessions.openSession(); + baz = (Baz) s.find("select baz from baz in class net.sf.hibernate.test.Baz order by baz").get(0); + Object o = baz.getFooComponentToFoo().get(new FooComponent("name", 123, null, null)); + assertTrue( + o==baz.getFooComponentToFoo().get(new FooComponent("nameName", 12, null, null)) && o!=null + ); + s2.connection().commit(); + s2.close(); assertTrue( baz.getTopFoos().size()==2 ); assertTrue( baz.getTopGlarchez().size()==1 ); *************** *** 702,711 **** assertTrue( baz.getBag().size()==4 ); assertTrue( baz.getFooToGlarch().size()==2 ); ! assertTrue( baz.getFooComponentToFoo().size()==1 ); assertTrue( baz.getGlarchToFoo().size()==1 ); Iterator iter = baz.getFooToGlarch().keySet().iterator(); for (int i=0; i<2; i++ ) assertTrue( iter.next() instanceof BarProxy ); FooComponent fooComp = (FooComponent) baz.getFooComponentToFoo().keySet().iterator().next(); ! assertTrue( fooComp.getCount()==123 && fooComp.getName().equals("name") && ( baz.getFooComponentToFoo().get(fooComp) instanceof BarProxy ) ); Glarch g2 = new Glarch(); s.save(g2); --- 711,724 ---- assertTrue( baz.getBag().size()==4 ); assertTrue( baz.getFooToGlarch().size()==2 ); ! assertTrue( baz.getFooComponentToFoo().size()==2 ); assertTrue( baz.getGlarchToFoo().size()==1 ); Iterator iter = baz.getFooToGlarch().keySet().iterator(); for (int i=0; i<2; i++ ) assertTrue( iter.next() instanceof BarProxy ); FooComponent fooComp = (FooComponent) baz.getFooComponentToFoo().keySet().iterator().next(); ! assertTrue( ! ( (fooComp.getCount()==123 && fooComp.getName().equals("name")) ! || (fooComp.getCount()==12 && fooComp.getName().equals("nameName")) ) ! && ( baz.getFooComponentToFoo().get(fooComp) instanceof BarProxy ) ! ); Glarch g2 = new Glarch(); s.save(g2); *************** *** 904,907 **** --- 917,924 ---- q = (Qux) s.load(Qux.class, q.getKey() ); b = (BarProxy) s.load( Foo.class, b.getKey() ); + b.getKey(); + assertFalse( Hibernate.isInitialized(b) ); + b.getBarString(); + assertTrue( Hibernate.isInitialized(b) ); BarProxy b2 = (BarProxy) s.load( Bar.class, new String( b.getKey() ) ); Qux q2 = (Qux) s.load( Qux.class, q.getKey() ); Index: FooComponent.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooComponent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FooComponent.java 3 Feb 2003 10:28:47 -0000 1.5 --- FooComponent.java 4 Apr 2003 13:52:00 -0000 1.6 *************** *** 15,18 **** --- 15,27 ---- private Baz baz; + public boolean equals(Object that) { + FooComponent fc = (FooComponent) that; + return count==fc.count; + } + + public int hashCode() { + return count; + } + public String toString() { String result = "FooComponent: " + name + "=" + count; |
From: <one...@us...> - 2003-04-04 13:52:04
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache In directory sc8-pr-cvs1:/tmp/cvs-serv7478/hibernate/cache Modified Files: ReadOnlyCache.java Timestamper.java Added Files: NonstrictReadWriteCache.java Log Message: added NonstrictReadWriteCache fixed problem with proxy.getId() for an interface proxy --- NEW FILE: NonstrictReadWriteCache.java --- package net.sf.hibernate.cache; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class NonstrictReadWriteCache implements CacheConcurrencyStrategy { private final Cache cache; private static final Log log = LogFactory.getLog(ReadWriteCache.class); public NonstrictReadWriteCache(Cache cache) { this.cache=cache; } public Object get(Object key, long txTimestamp) throws CacheException { Object result = cache.get(key); if ( result!=null && !(result instanceof Long) ) { if ( log.isDebugEnabled() ) log.debug("Cache hit: " + key); return result; } return null; } public void lock(Object key) throws CacheException { //cache.put(key, null); } public boolean put(Object key, Object value, long txTimestamp) throws CacheException { Object result = cache.get(key); if ( result==null ) { if ( log.isDebugEnabled() ) log.debug("Caching new: " + key); } else if ( result instanceof Long && ( (Long) result ).longValue() < txTimestamp / Timestamper.ONE_MS // note that this is not guaranteed to be correct in a cluster // because system times could be inconsistent ) { if ( log.isDebugEnabled() ) log.debug("Caching invalidated: " + key); } else { return false; //note early exit } cache.put(key, value); return true; } public void release(Object key) throws CacheException { if ( log.isDebugEnabled() ) log.debug("Invalidating: " + key); cache.put( key, new Long( Timestamper.next() / Timestamper.ONE_MS ) ); } } Index: ReadOnlyCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/ReadOnlyCache.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReadOnlyCache.java 5 Jan 2003 02:11:20 -0000 1.3 --- ReadOnlyCache.java 4 Apr 2003 13:51:59 -0000 1.4 *************** *** 20,24 **** public synchronized Object get(Object key, long timestamp) throws CacheException { Object result = cache.get(key); ! if ( result!=null ) log.debug("Cache hit: " + key); return result; } --- 20,24 ---- public synchronized Object get(Object key, long timestamp) throws CacheException { Object result = cache.get(key); ! if ( result!=null && log.isDebugEnabled() ) log.debug("Cache hit: " + key); return result; } *************** *** 30,34 **** public synchronized boolean put(Object key, Object value, long timestamp) throws CacheException { ! log.debug("Caching: " + key); cache.put(key, value); return true; --- 30,34 ---- public synchronized boolean put(Object key, Object value, long timestamp) throws CacheException { ! if ( log.isDebugEnabled() ) log.debug("Caching: " + key); cache.put(key, value); return true; Index: Timestamper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/Timestamper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Timestamper.java 5 Jan 2003 02:11:20 -0000 1.3 --- Timestamper.java 4 Apr 2003 13:51:59 -0000 1.4 *************** *** 10,22 **** private static short counter = 0; private static long time; public synchronized static long next() { ! long newTime = System.currentTimeMillis() << 16; if (time<newTime) { time = newTime; counter = 0; } ! else if (counter<Short.MAX_VALUE) { counter++; } --- 10,24 ---- private static short counter = 0; private static long time; + private static final int BIN_DIGITS = 12; + public static final short ONE_MS = 1<<BIN_DIGITS; public synchronized static long next() { ! long newTime = System.currentTimeMillis() << BIN_DIGITS; if (time<newTime) { time = newTime; counter = 0; } ! else if (counter < ONE_MS - 1 ) { counter++; } |
From: <one...@us...> - 2003-04-04 13:52:04
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv7478/hibernate/cfg Modified Files: Configuration.java Log Message: added NonstrictReadWriteCache fixed problem with proxy.getId() for an interface proxy Index: Configuration.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Configuration.java 29 Mar 2003 04:08:46 -0000 1.18 --- Configuration.java 4 Apr 2003 13:51:59 -0000 1.19 *************** *** 46,49 **** --- 46,50 ---- import net.sf.hibernate.cache.CacheException; import net.sf.hibernate.cache.JCSCache; + import net.sf.hibernate.cache.NonstrictReadWriteCache; import net.sf.hibernate.cache.ReadOnlyCache; import net.sf.hibernate.cache.ReadWriteCache; *************** *** 779,782 **** --- 780,786 ---- else if ( usage.equals("read-write") ) { return new ReadWriteCache(jcs); + } + else if ( usage.equals("nonstrict-read-write") ) { + return new NonstrictReadWriteCache(jcs); } else { |
From: <one...@us...> - 2003-04-04 13:52:04
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv7478/hibernate/persister Modified Files: AbstractEntityPersister.java Log Message: added NonstrictReadWriteCache fixed problem with proxy.getId() for an interface proxy Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AbstractEntityPersister.java 29 Mar 2003 07:36:22 -0000 1.16 --- AbstractEntityPersister.java 4 Apr 2003 13:51:59 -0000 1.17 *************** *** 522,526 **** Method proxyGetter = identifierGetter.getMethod(); try { ! proxyGetter = ReflectHelper.getGetter( model.getProxyInterface(), identifierPropertyName ).getMethod(); } catch (Exception e) {} --- 522,530 ---- Method proxyGetter = identifierGetter.getMethod(); try { ! proxyGetter = ReflectHelper.getGetter( ! // model.getProxyInterface(), //we used this for old dynamic proxies ! mappedClass, //we use this for new CGLIB proxies ! identifierPropertyName ! ).getMethod(); } catch (Exception e) {} |
From: <one...@us...> - 2003-04-03 12:34:36
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util In directory sc8-pr-cvs1:/tmp/cvs-serv28961/hibernate/util Modified Files: StringHelper.java Log Message: * improved foreign id-generator * fixed a bug with long path expressions ending in elements or indices in where clause Index: StringHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/StringHelper.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** StringHelper.java 20 Mar 2003 13:59:10 -0000 1.12 --- StringHelper.java 3 Apr 2003 12:34:30 -0000 1.13 *************** *** 178,181 **** --- 178,182 ---- for ( int i=0; i<names.length; i++ ) names[i] = unQuote( names[i] ); } + public static String[] unQuote(String[] names) { String[] unquoted = new String[ names.length ]; |
From: <one...@us...> - 2003-04-03 12:34:36
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv28961/hibernate/test Modified Files: FooBarTest.java XY.hbm.xml Y.java Log Message: * improved foreign id-generator * fixed a bug with long path expressions ending in elements or indices in where clause Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** FooBarTest.java 29 Mar 2003 04:08:49 -0000 1.45 --- FooBarTest.java 3 Apr 2003 12:34:29 -0000 1.46 *************** *** 80,83 **** --- 80,126 ---- } + public void testOneToOneGenerator() throws Exception { + Session s = sessions.openSession(); + X x = new X(); + Y y = new Y(); + x.setY(y); + y.setTheX(x); + Serializable id = s.save(y); + assertEquals( id, s.save(x) ); + s.flush(); + assertTrue( s.contains(y) && s.contains(x) ); + s.connection().commit(); + s.close(); + assertEquals( new Long(x.getId()), y.getId() ); + + s = sessions.openSession(); + x = new X(); + y = new Y(); + x.setY(y); + y.setTheX(x); + s.save(y); + s.flush(); + assertTrue( s.contains(y) && s.contains(x) ); + s.connection().commit(); + s.close(); + assertEquals( new Long(x.getId()), y.getId() ); + + s = sessions.openSession(); + x = new X(); + y = new Y(); + x.setY(y); + y.setTheX(x); + id = s.save(x); + assertEquals( id, y.getId() ); + assertEquals( id, new Long( x.getId() ) ); + s.flush(); + assertTrue( s.contains(y) && s.contains(x) ); + s.delete("from X x"); + s.flush(); + s.connection().commit(); + s.close(); + + } + public void testNamedParams() throws Exception { Bar bar = new Bar(); *************** *** 412,415 **** --- 455,468 ---- assertTrue( list.size()==2 && ( list.get(0) instanceof Result ) && ( list.get(1) instanceof Result ) ); + s.find("select max( elements(bar.baz.fooArray) ) from Bar as bar"); + s.find("select count(*) from Baz as baz where 1 in indices(baz.fooArray)"); + s.find("select count(*) from Bar as bar where 'abc' in elements(bar.baz.fooArray)"); + s.find("select count(*) from Bar as bar where 1 in indices(bar.baz.fooArray)"); + s.find("select count(*) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)"); + s.find("select max( elements(bar.baz.fooArray) ) from Bar as bar, bar.component.glarch.proxyArray as g where g.id in indices(bar.baz.fooArray)"); + + s.find("select count(*) from Bar as bar where 1 in (from g in bar.component.glarch.proxyArray where g.name='foo')"); + s.find("select count(*) from Bar as bar left outer join bar.component.glarch.proxyArray as pg where 1 in (from g in bar.component.glarch.proxyArray)"); + s.find("select baz.name from Bar bar inner join bar.baz baz inner join baz.fooSet foo where baz.name = bar.string"); s.find("SELECT baz.name FROM Bar AS bar INNER JOIN bar.baz AS baz INNER JOIN baz.fooSet AS foo WHERE baz.name = bar.string"); *************** *** 2773,2788 **** } ! public void testOneToOneGenerator() throws Exception { ! Session s = sessions.openSession(); ! X x = new X(); ! Y y = new Y(); ! x.setY(y); ! s.save(y); ! s.save(x); ! s.flush(); ! s.connection().commit(); ! s.close(); ! } ! public void testAny() throws Exception { Session s = sessions.openSession(); --- 2826,2830 ---- } ! public void testAny() throws Exception { Session s = sessions.openSession(); Index: XY.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/XY.hbm.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XY.hbm.xml 29 Mar 2003 04:20:19 -0000 1.1 --- XY.hbm.xml 3 Apr 2003 12:34:30 -0000 1.2 *************** *** 5,14 **** <hibernate-mapping> <class name="net.sf.hibernate.test.X"> ! <id name="id"> <generator class="foreign"> <param name="property">y</param> </generator> </id> ! <one-to-one name="y" constrained="true"/> </class> <class name="net.sf.hibernate.test.Y"> --- 5,14 ---- <hibernate-mapping> <class name="net.sf.hibernate.test.X"> ! <id name="id" unsaved-value="0"> <generator class="foreign"> <param name="property">y</param> </generator> </id> ! <one-to-one name="y" constrained="true" cascade="all"/> </class> <class name="net.sf.hibernate.test.Y"> *************** *** 17,20 **** --- 17,21 ---- </id> <property name="x"/> + <one-to-one name="theX" cascade="save-update"/> </class> </hibernate-mapping> Index: Y.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Y.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Y.java 29 Mar 2003 04:20:19 -0000 1.1 --- Y.java 3 Apr 2003 12:34:30 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- private Long id; private String x; + private X theX; /** * Returns the id. *************** *** 36,39 **** --- 37,54 ---- public void setX(String x) { this.x = x; + } + + /** + * @return + */ + public X getTheX() { + return theX; + } + + /** + * @param x + */ + public void setTheX(X x) { + theX = x; } |
From: <one...@us...> - 2003-04-03 12:34:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id In directory sc8-pr-cvs1:/tmp/cvs-serv28961/hibernate/id Modified Files: ForeignGenerator.java IdentifierGeneratorFactory.java Log Message: * improved foreign id-generator * fixed a bug with long path expressions ending in elements or indices in where clause Index: ForeignGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id/ForeignGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ForeignGenerator.java 29 Mar 2003 04:20:18 -0000 1.1 --- ForeignGenerator.java 3 Apr 2003 12:34:28 -0000 1.2 *************** *** 20,24 **** */ public class ForeignGenerator implements IdentifierGenerator, Configurable { ! private String propertyName; --- 20,24 ---- */ public class ForeignGenerator implements IdentifierGenerator, Configurable { ! private String propertyName; *************** *** 32,36 **** .getClassMetadata( object.getClass() ) .getPropertyValue(object, propertyName); ! return session.getEntityIdentifierIfNotUnsaved(associatedObject); } --- 32,43 ---- .getClassMetadata( object.getClass() ) .getPropertyValue(object, propertyName); ! //return session.getEntityIdentifierIfNotUnsaved(associatedObject); ! Serializable id = session.save(associatedObject); ! if ( session.contains(object) ) { ! //abort the save (the object is already saved by a circular cascade) ! return IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR; ! //throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association"); ! } ! return id; } Index: IdentifierGeneratorFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id/IdentifierGeneratorFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierGeneratorFactory.java 29 Mar 2003 04:20:18 -0000 1.3 --- IdentifierGeneratorFactory.java 3 Apr 2003 12:34:29 -0000 1.4 *************** *** 15,19 **** * Factory methods for <tt>IdentifierGenerator</tt> framework */ ! public class IdentifierGeneratorFactory { // unhappy about this being public ... is there a better way? --- 15,19 ---- * Factory methods for <tt>IdentifierGenerator</tt> framework */ ! public final class IdentifierGeneratorFactory { // unhappy about this being public ... is there a better way? *************** *** 34,37 **** --- 34,39 ---- private static final HashMap idgenerators = new HashMap(); + + public static final String SHORT_CIRCUIT_INDICATOR = new String(); static { idgenerators.put("uuid.hex", UUIDHexGenerator.class); *************** *** 84,87 **** --- 86,91 ---- } } + + private IdentifierGeneratorFactory() {} //cannot be instantiated } |
From: <one...@us...> - 2003-04-03 12:34:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv28961/hibernate/hql Modified Files: PathExpressionParser.java QueryTranslator.java WhereParser.java Log Message: * improved foreign id-generator * fixed a bug with long path expressions ending in elements or indices in where clause Index: PathExpressionParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/PathExpressionParser.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PathExpressionParser.java 29 Mar 2003 04:08:47 -0000 1.15 --- PathExpressionParser.java 3 Apr 2003 12:34:24 -0000 1.16 *************** *** 22,25 **** --- 22,29 ---- public class PathExpressionParser implements Parser { + //TODO: this class does too many things! we need a different + //kind of path expression parser for each of the diffferent + //ways in which path expressions can occur + public static final String ENTITY_ID = "id"; public static final String ENTITY_CLASS = "class"; *************** *** 46,49 **** --- 50,54 ---- private String path; private boolean skippedId; + private boolean ignoreInitialJoin; private boolean continuation; private int joinType = JoinFragment.INNER_JOIN; //default mode *************** *** 68,71 **** --- 73,80 ---- } + public void ignoreInitialJoin() { + ignoreInitialJoin=true; + } + public void token(String token, QueryTranslator q) throws QueryException { *************** *** 76,81 **** reset(q); //reset the dotcount (but not the path) currentName = alias; //after reset! ! JoinFragment ojf = q.getPathJoin(path); ! join.addCondition( ojf.toWhereFragmentString() ); //after reset! } else if ( ".".equals(token) ) { --- 85,92 ---- reset(q); //reset the dotcount (but not the path) currentName = alias; //after reset! ! if (!ignoreInitialJoin) { ! JoinFragment ojf = q.getPathJoin(path); ! join.addCondition( ojf.toWhereFragmentString() ); //after reset! ! } } else if ( ".".equals(token) ) { *************** *** 241,244 **** --- 252,256 ---- public void end(QueryTranslator q) throws QueryException { + ignoreInitialJoin = false; if ( isCollectionValued() ) { columns = collectionElementColumns; *************** *** 350,357 **** .append( StringHelper.join( ", ", collectionElementColumns ) ) .append(" FROM ") ! .append(collectionTable) .append(' ') ! .append(collectionName) ! //.append( join.toFromFragmentString() ) .append(" WHERE ") .append( join.toWhereFragmentString().substring(5) ) // remove initial " and " --- 362,369 ---- .append( StringHelper.join( ", ", collectionElementColumns ) ) .append(" FROM ") ! /*.append(collectionTable) .append(' ') ! .append(collectionName)*/ ! .append( join.toFromFragmentString().substring(2) ) // remove initial ", " .append(" WHERE ") .append( join.toWhereFragmentString().substring(5) ) // remove initial " and " Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** QueryTranslator.java 29 Mar 2003 04:08:47 -0000 1.22 --- QueryTranslator.java 3 Apr 2003 12:34:24 -0000 1.23 *************** *** 701,705 **** } - protected void bindNamedParameters(PreparedStatement ps, Map namedParams, SessionImplementor session) throws SQLException, HibernateException { if (namedParams!=null) { --- 701,704 ---- Index: WhereParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/WhereParser.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** WhereParser.java 3 Mar 2003 09:31:06 -0000 1.11 --- WhereParser.java 3 Apr 2003 12:34:25 -0000 1.12 *************** *** 334,339 **** } private void doPathExpression(String token, QueryTranslator q) throws QueryException { ! q.unalias(token); StringTokenizer tokens = new StringTokenizer(token, ".", true); pathExpressionParser.start(q); --- 334,360 ---- } + private void preprocess(String token, QueryTranslator q) throws QueryException { + // ugly hack for cases like "foo.bar.collection.elements" + // (multi-part path expression ending in elements or indices) + String[] tokens = StringHelper.split(".", token, true); + if ( + tokens.length>5 && + ( "elements".equals( tokens[tokens.length-1] ) || "indices".equals( tokens[tokens.length-1] ) ) + ) { + pathExpressionParser.start(q); + for( int i=0; i<tokens.length-3; i++ ) { + pathExpressionParser.token( tokens[i], q); + } + pathExpressionParser.token(null, q); + pathExpressionParser.end(q); + addJoin( pathExpressionParser.getWhereJoin(), q ); + pathExpressionParser.ignoreInitialJoin(); + } + } + private void doPathExpression(String token, QueryTranslator q) throws QueryException { ! ! preprocess(token, q); ! StringTokenizer tokens = new StringTokenizer(token, ".", true); pathExpressionParser.start(q); *************** *** 353,364 **** } else { ! JoinFragment ojf = pathExpressionParser.getWhereJoin(); ! JoinFragment fromClause = q.createJoinFragment(); ! fromClause.addJoins( ojf.toFromFragmentString(), StringHelper.EMPTY_STRING ); ! q.addJoin( pathExpressionParser.getName(), fromClause ); ! addToCurrentJoin( ojf.toWhereFragmentString() ); appendToken( q, pathExpressionParser.getWhereColumn() ); } } } --- 374,388 ---- } else { ! addJoin( pathExpressionParser.getWhereJoin(), q ); appendToken( q, pathExpressionParser.getWhereColumn() ); } } + } + + private void addJoin(JoinFragment ojf, QueryTranslator q) { + JoinFragment fromClause = q.createJoinFragment(); + fromClause.addJoins( ojf.toFromFragmentString(), StringHelper.EMPTY_STRING ); + q.addJoin( pathExpressionParser.getName(), fromClause ); + addToCurrentJoin( ojf.toWhereFragmentString() ); } |
From: <one...@us...> - 2003-04-03 12:34:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv28961/hibernate/impl Modified Files: SessionImpl.java Log Message: * improved foreign id-generator * fixed a bug with long path expressions ending in elements or indices in where clause Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** SessionImpl.java 2 Apr 2003 01:06:52 -0000 1.30 --- SessionImpl.java 3 Apr 2003 12:34:29 -0000 1.31 *************** *** 72,75 **** --- 72,76 ---- import net.sf.hibernate.hql.QueryTranslator; import net.sf.hibernate.hql.FilterTranslator; + import net.sf.hibernate.id.IdentifierGeneratorFactory; /** *************** *** 581,584 **** --- 582,586 ---- try { id = getPersister(object).getIdentifierGenerator().generate(this, object); + if (id==IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR) return getIdentifier(object); //TODO: yick! } catch (SQLException sqle) { |
From: <tu...@us...> - 2003-04-03 01:43:34
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv11450/src Modified Files: index.xml Added Files: toolset_guide.xml Log Message: Added toolset guide to reference docs --- NEW FILE: toolset_guide.xml --- <chapter id="toolsetguide"> <title>Toolset Guide</title> <para> Hibernate supports roundtrip engineering with a set of tools for DDL schema generation from a mapping file, mapping file generation from Java source code, Java class generation from a mapping file and a reverse engineering tool to generate Java classes and mapping files from an existing database schema. </para> <para> A set of example DOS batch files for the toolset is located in the <literal>bin</literal>-directory of the Hibernate distribution. </para> <sect1 id="toolsetguide-s1"> <title>Schema Generation</title> <para> A schema can be generated from your mapping file/s through a command line utility: </para> <para> <literal>net.sf.hibernate.tool.hbm2ddl.SchemaExport</literal> </para> <para> The generated schema include referential integrity constraints (primary and foreign keys) for entity tables, and indexes and foreign keys for collection tables. Tables are also created for all instances of <literal>HiLoGenerator</literal>. <literal>HiLoGenerator</literal> tables are specified in the elements of the <literal><generator></literal> tag. </para> <sect2 id="toolsetguide-s1-1"> <title>SQL Dialects</title> <para> Schema generation works for all officially supported databases (DB2, Postgres, Oracle, MySQL, Sybase, Microsoft SQL Server, HypersonicSQL, Progress, Interbase, Pointbase, McKoi and SAP DB). Other products may be supported by subclassing <literal>net.sf.hibernate.dialect.Dialect</literal>. If you do implement <literal>Dialect</literal> for any database not on our list, please contribute it back to the project. </para> <table frame="all"> <title>Hibernate SQL Dialects (<literal>hibernate.dialect</literal>)</title> <tgroup cols="2"> <colspec colwidth="1*"/> <colspec colwidth="2.5*"/> <thead> <row> <entry>RDBMS</entry> <entry>Dialect</entry> </row> </thead> <tbody> <row> <entry>DB2</entry> <entry><literal>net.sf.hibernate.dialect.DB2Dialect</literal></entry> </row> <row> <entry>MySQL</entry> <entry><literal>net.sf.hibernate.dialect.MySQLDialect</literal></entry> </row> <row> <entry>SAP DB</entry> <entry><literal>net.sf.hibernate.dialect.SAPDBDialect</literal></entry> </row> <row> <entry>Oracle (any version)</entry> <entry><literal>net.sf.hibernate.dialect.OracleDialect</literal></entry> </row> <row> <entry>Oracle 9</entry> <entry><literal>net.sf.hibernate.dialect.Oracle9Dialect</literal></entry> </row> <row> <entry>Sybase</entry> <entry><literal>net.sf.hibernate.dialect.SybaseDialect</literal></entry> </row> <row> <entry>Progress</entry> <entry><literal>net.sf.hibernate.dialect.ProgressDialect</literal></entry> </row> <row> <entry>Mckoi SQL</entry> <entry><literal>net.sf.hibernate.dialect.McKoiDialect</literal></entry> </row> <row> <entry>Interbase</entry> <entry><literal>net.sf.hibernate.dialect.InterbaseDialect</literal></entry> </row> <row> <entry>Pointbase</entry> <entry><literal>net.sf.hibernate.dialect.PointbaseDialect</literal></entry> </row> <row> <entry>PostgreSQL</entry> <entry><literal>net.sf.hibernate.dialect.PostgreSQLDialect</literal></entry> </row> <row> <entry>HypersonicSQL</entry> <entry><literal>net.sf.hibernate.dialect.HSQLDialect</literal></entry> </row> <row> <entry>Microsoft SQL Server</entry> <entry><literal>net.sf.hibernate.dialect.SybaseDialect</literal></entry> </row> <row> <entry>Ingres</entry> <entry><literal>net.sf.hibernate.dialect.IngresDialect</literal></entry> </row> <row> <entry>FrontBase</entry> <entry><literal>net.sf.hibernate.dialect.FrontbaseDialect</literal></entry> </row> </tbody> </tgroup> </table> </sect2> <sect2 id="toolsetguide-s1-2"> <title>Customizing the Schema</title> <para> The <literal><id></literal>, <literal><discriminator></literal>, <literal><property></literal>, <literal><key></literal>, <literal><index></literal>, <literal><element></literal>, <literal><many-to-one></literal>, <literal><many-to-many></literal> and <literal><column></literal> tags take an optional attribute named <literal>length</literal>. You may set the <literal>length</literal> of a generated character or binary column with this attribute. </para> <para> Some tags also accept a <literal>not-null</literal> attribute (for generating a <literal>NOT NULL</literal> constraint on table columns) and a <literal>unique</literal> attribute (for generating <literal>UNIQUE</literal> constraint on table columns). </para> <para> Some tags accept an <literal>index</literal> attribute for specifying the name of an index for that column. </para> <para> Examples: </para> <programlisting><![CDATA[<property name="foo" type="string" length="64" not-null="true"/> <subcollection column="serial_numbers" role="serial-numbers" not-null="true" unique="true"/> <element column="serial_number" type="long" not-null="true" unique="true"/>]]></programlisting> <para> Alternatively, these elements also accept a child <literal><column></literal> element. This is particularly useful for multi-column types: </para> <programlisting><![CDATA[<property name="foo" type="string"> <column name="foo" length="64" not-null="true" sql-type="text"/> </property> <subcollection role="serial-numbers"/> <column name="serial_numbers" not-null="true" unique="true"/> </subcollection> <property name="bar" type="my.customtypes.MultiColumnType"/> <column name="fee" not-null="true" index="bar_idx"/> <column name="fi" not-null="true" index="bar_idx"/> <column name="fo" not-null="true" index="bar_idx"/> </property>]]></programlisting> <para> The <literal>sql-type</literal> attribute allows the user to override the default mapping of Hibernate type to SQL datatype. </para> </sect2> <sect2 id="toolsetguide-s1-3"> <title>Running the tool</title> <para> The <literal>SchemaExport</literal> tool writes a DDL script to standard out and/or executes the script immediately on the database. </para> <para> <literal>java -cp </literal><emphasis>hibernate_classpaths</emphasis> <literal>net.sf.hibernate.tool.hbm2ddl.SchemaExport</literal> <emphasis>options mapping_files</emphasis> </para> <table frame="all"> <title>SchemaExport Command Line Options</title> <tgroup cols="2"> <colspec colwidth="1.5*"/> <colspec colwidth="2*"/> <thead> <row> <entry>Option</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>--quiet</literal></entry> <entry>don't output the script to stdout</entry> </row> <row> <entry><literal>--drop</literal></entry> <entry>only drop the tables</entry> </row> <row> <entry><literal>--text</literal></entry> <entry>don't export to the database</entry> </row> <row> <entry><literal>--output=my_schema.ddl</literal></entry> <entry>output the ddl script to a file</entry> </row> <row> <entry><literal>--properties=hibernate.properties</literal></entry> <entry>read database properties from a file</entry> </row> <row> <entry><literal>--format</literal></entry> <entry>format the generated SQL nicely in the script</entry> </row> <row> <entry><literal>--delimiter=x</literal></entry> <entry>set an end of line delimiter for the script</entry> </row> </tbody> </tgroup> </table> <para> Optionally, you can control the <literal>SchemaExport</literal> tool in your application: </para> <programlisting><![CDATA[Datastore ds; new net.sf.hibernate.tool.hbm2ddl.SchemaExport(ds, properties).create(false, true);]]></programlisting> </sect2> <sect2 id="toolsetguide-s1-4"> <title>Properties</title> <para> Database properties may be specified </para> <itemizedlist spacing="compact"> <listitem> <para>as system properties with -D<emphasis><property></emphasis></para> </listitem> <listitem> <para>in <literal>hibernate.properties</literal></para> </listitem> <listitem> <para>in a named properties file with <literal>--properties</literal></para> </listitem> </itemizedlist> <para> The needed properties are: </para> <itemizedlist spacing="compact"> <listitem> <para><literal>hibernate.connection.driver = </literal> <emphasis>jdbc driver class</emphasis></para> </listitem> <listitem> <para><literal>hibernate.connection.url = </literal> <emphasis>jdbc url</emphasis></para> </listitem> <listitem> <para><literal>hibernate.connection.username = </literal> <emphasis>database user</emphasis></para> </listitem> <listitem> <para><literal>hibernate.connection.password = </literal> <emphasis>user password</emphasis></para> </listitem> <listitem> <para><literal>hibernate.dialect = </literal> <emphasis>dialect</emphasis></para> </listitem> </itemizedlist> </sect2> <sect2 id="toolsetguide-s1-5"> <title>Using Ant</title> <para> You can call the <literal>SchemaExport</literal> tool from your Ant build script: </para> <programlisting><![CDATA[<target name="initdb" depends="compile"> <java classname="cirrus.hibernate.tools.SchemaExport" fork="true"> <!-- mapping file --> <arg value="/projects/smis/src/resources/web/WEB-INF/mapping.xml"/> <jvmarg value="-Dhibernate.dialect=cirrus.hibernate.sql.SybaseDialect"/> <jvmarg value="-Dhibernate.connection.driver_class=com.inet.tds.TdsDriver"/> <jvmarg value="-Dhibernate.connection.url=jdbc:inetdae:localhost:1433"/> <jvmarg value="-Dhibernate.connection.username=xxx"/> <jvmarg value="-Dhibernate.connection.password=xxx"/> <classpath> <fileset dir="${basedir}/lib"> <include name="**/*.jar" /> </fileset> <!-- build output path --> <pathelement location="${build.dir}/classes/web/WEB-INF/classes"/> </classpath> </java> </target>]]></programlisting> </sect2> </sect1> <sect1 id="toolsetguide-s2"> <title>Map Generation</title> <para> A skeleton O-R mapping file may be generated for your persistent classes through a command line utility in </para> <para> <literal>src.net.sf.hibernate.tool.class2hbm.MapGenerator</literal> </para> <para> MapGenerator provides a mechanism to produce a Hibernate XML OR-Mapping from compiled classes. It does this using Java reflection to find <emphasis>properties</emphasis> to be persisted in the classes, and using the types of the properties to further guide the reflection. </para> <para> The generated mapping is intended to be a starting point only. There is no way to produce a full Hibernate O-R mapping without extra input from the user. However, the tool does take away some of the repetitive "grunt" work involved in producing a mapping. </para> <para> Classes are added to the mapping one at a time. <literal>MapGenerator</literal> will reject classes that it judges are are not <emphasis>Hibernate persistable</emphasis>. </para> <para> To be <emphasis>Hibernate persistable</emphasis> a class </para> <itemizedlist spacing="compact"> <listitem> <para>must not be a primitive type</para> </listitem> <listitem> <para>must not be an array</para> </listitem> <listitem> <para>must not be an interface</para> </listitem> <listitem> <para>must not be a nested class</para> </listitem> <listitem> <para>must have a default (zero argument) constructor.</para> </listitem> </itemizedlist> <para> Note that interfaces and nested classes actually are persistable by Hibernate, but this would not usually be intended by the user. </para> <para> <literal>MapGenerator</literal> will climb the superclass chain of all added classes attempting to add as many Hibernate persistable superclasses as possible to the same database table. The search stops as soon as a property is found that has a name appearing on a list of <emphasis>candidate UID names</emphasis>. </para> <para> The default list of candidate UID property names is: <literal>uid</literal>, <literal>UID</literal>, <literal>id</literal>, <literal>ID</literal>, <literal>key</literal>, <literal>KEY</literal>, <literal>pk</literal>, <literal>PK</literal>. </para> <para> Properties are discovered when there are two methods in the class, a setter and a getter, where the type of the setter's single argument is the same as the return type of the zero argument getter, and the setter returns <literal>void</literal>. Furthermore, the setter's name must start with the string <literal>set</literal> and either the getter's name starts with <literal>get</literal> or the getter's name starts with <literal>is</literal> and the type of the property is boolean. In either case, the remainder of their names must match. This matching portion is the name of the property, except that the initial character of the property name is made lower case if the second letter is lower case. </para> <para> The rules for determining the database type of each property are as follows: </para> <orderedlist spacing="compact"> <listitem> <para> If the Java type is <literal>Hibernate.basic()</literal>, then the property is a simple column of that type. </para> </listitem> <listitem> <para> For <literal>hibernate.type.Type</literal> custom types and <literal>PersistentEnum</literal> a simple column is used as well. </para> </listitem> <listitem> <para> If the property type is an array, then a Hibernate array is used, and <literal>MapGenerator</literal> attempts to reflect on the array element type. </para> </listitem> <listitem> <para> If the property has type <literal>java.util.List</literal>, <literal>java.util.Map</literal>, or <literal>java.util.Set</literal>, then the corresponding Hibernate types are used, but <literal>MapGenerator</literal> cannot further process the insides of these types. </para> </listitem> <listitem> <para> If the property's type is any other class, <literal>MapGenerator</literal> defers the decision on the database representation until all classes have been processed. At this point, if the class was discovered through the superclass search described above, then the property is an <literal>many-to-one</literal> association. If the class has any properties, then it is a <literal>component</literal>. Otherwise it is serializable, or not persistable. </para> </listitem> </orderedlist> <sect2 id="toolsetguide-s2-1"> <title>Running the tool</title> <para> The tool writes XML O-R mapping to standard out and/or to a file. </para> <para> When invoking <literal>MapGenerator</literal> you must place your compiled classes on the classpath, and start Java in the <literal>MapGenerator.main()</literal> method. </para> <para> <literal>java -cp </literal><emphasis>hibernate_and_your_class_classpaths</emphasis> <literal>src.net.sf.hibernate.tool.class2hbm.MapGenerator</literal> <emphasis>options and classnames</emphasis> </para> <para> There are two modes of operation: command line or interactive. </para> <para> The interactive mode is selected by providing the single command line argument <literal>--interact</literal>. This mode provides a prompt response console. Using it you can set the UID property name for each class using the <literal>uid=XXX</literal> command where <literal>XXX</literal> is the UID property name. Other command alternatives are simply a fully qualified class name, or the command done which emits the XML and terminates. </para> <para> In command line mode the arguments are the options below interspersed with fully qualified class names of the classes to be processed. Most of the options are meant to be used multiple times; each use affects subsequently added classes. </para> <table frame="all"> <title>MapGenerator Command Line Options</title> <tgroup cols="2"> <colspec colwidth="1*"/> <colspec colwidth="2*"/> <thead> <row> <entry>Option</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>--quiet</literal></entry> <entry>don't output the O-R Mapping to stdout</entry> </row> <row> <entry><literal>--setUID=uid</literal></entry> <entry>set the list of candidate UIDs to the singleton uid</entry> </row> <row> <entry><literal>--addUID=uid</literal></entry> <entry>add uid to the front of the list of candidate UIDs</entry> </row> <row> <entry><literal>--select=</literal><emphasis>mode</emphasis></entry> <entry>mode use select mode <emphasis>mode</emphasis>(e.g., <emphasis>distinct</emphasis> or <emphasis>all</emphasis>) for subsequently added classes</entry> </row> <row> <entry><literal>--depth=<small-int></literal></entry> <entry>limit the depth of component data recursion for subsequently added classes</entry> </row> <row> <entry><literal>--output=my_mapping.xml</literal></entry> <entry>output the O-R Mapping to a file</entry> </row> <row> <entry><emphasis>full.class.Name</emphasis></entry> <entry>add the class to the mapping</entry> </row> <row> <entry><literal>--abstract=</literal><emphasis>full.class.Name</emphasis></entry> <entry>see below</entry> </row> </tbody> </tgroup> </table> <para> The abstract switch directs the map generator tool to ignore specific super classes so that classes with common inheritance are not mapped to one large table. For instance, consider these class hierarchies: </para> <para> <literal>Animal-->Mammal-->Human</literal> </para> <para> <literal>Animal-->Mammal-->Marsupial-->Kangaroo</literal> </para> <para> If the <literal>--abstract</literal>switch is <emphasis>not</emphasis> used, all classes will be mapped as subclasses of <literal>Animal</literal>, resulting in one large table containing all the properties of all the classes plus a discriminator column to indicate which subclass is actually stored. If <literal>Mammal</literal> is marked as <literal>abstract</literal>, <literal>Human</literal> and <literal>Marsupial</literal> will be mapped to separate <literal><class></literal> declarations and stored in separate tables. <literal>Kangaroo</literal> will still be a subclass of <literal>Marsupial</literal> unless <literal>Marsupial</literal> is also marked as <literal>abstract</literal>. </para> </sect2> </sect1> <sect1 id="toolsetguide-s3"> <title>Code Generation</title> <para> The Code Generator may be used to generate skeletal Java implementation classes of a hibernate mapping file. </para> <para> <literal>java -cp</literal> <emphasis>hibernate_classpaths</emphasis> <literal>net.sf.hibernate.tool.hbm2java.CodeGenerator</literal> <emphasis> options mapping_files</emphasis> </para> <table frame="all"> <title>Code Generator Command Line Options</title> <tgroup cols="2"> <colspec colwidth="1*"/> <colspec colwidth="2*"/> <thead> <row> <entry>Option</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>--output=</literal><emphasis>output_dir</emphasis></entry> <entry>root directory for generated code</entry> </row> </tbody> </tgroup> </table> </sect1> <sect1 id="toolsetguide-s4"> <title>Reverse Engineering Tool</title> <para> The Reverse Engineering Tool may be used to generate Hibernate mapping files and Java source files from an existing database schema. Using database metadata, the tool retrieves table and column information and generates appropriate mapping files and Java source. </para> <para> The tool is implemented as a small Swing application with several configuration screens: </para> <sect2 id="toolsetguide-s4-1"> <title>Connection Panel</title> <para> Configure the JDBC connection here. Note that the specified JDBC driver class must be in the classpath. </para> </sect2> <sect2 id="toolsetguide-s4-2"> <title>Tables</title> <para> Select the tables for generation in this panel. Start by clicking the tables button at the top of the panel. Specify a catalog, schema, and table name pattern in the resulting dialog (the table name pattern is specified using SQL <literal>like</literal> syntax). On exiting the dialog, the tables panel will display the selected database tables. You may select one or more tables for generation. </para> </sect2> <sect2 id="toolsetguide-s4-3"> <title>Mapping</title> <para> The mapping panel may be used to configure the mapping file generator. </para> <itemizedlist spacing="compact"> <listitem> <para> <literal>Mapping File</literal> - select to generate one mapping file for each database table, or to generate a single map for all tables. </para> </listitem> <listitem> <para> <literal>Key Field Name</literal> - specify the name of the identifier property used in each Hibernate class. </para> </listitem> <listitem> <para> <literal>Generator</literal> - select the Hibernate generator that will assign identifier values. The <literal>params</literal> button produces a dialog for configuring generator parameters. </para> </listitem> <listitem> <para> <literal>Key Field Type</literal> - select Hibernate types or Java types. Selecting Hibernate types will result in Java source using primitive field types, selecting Java types will result in Java source using object types (<literal>Integer</literal>, etc.). </para> </listitem> <listitem> <para> <literal>Key Field Class</literal> - specify the type of key field to be used in the mapping file and generated source. </para> </listitem> </itemizedlist> </sect2> <sect2 id="toolsetguide-s4-4"> <title>Code</title> <itemizedlist spacing="compact"> <listitem> <para> <literal>Package Name</literal> - sets the package name for generated Java source. </para> </listitem> <listitem> <para> <literal>Base Class Name</literal> - set a base class for generated Java source files. useful if you want to consolidate common behavior in Hibernate classes. </para> </listitem> </itemizedlist> </sect2> <sect2 id="toolsetguide-s4-5"> <title>Output</title> <itemizedlist spacing="compact"> <listitem> <para> <literal>Output Directory</literal> - sets the output directory for the generated mapping file and Java sources. Note that all files will be created in a directory according to the package name, relative to the output directory specified here. </para> </listitem> <listitem> <para> <literal>Base Class Name</literal> - set a base class for generated Java source files. useful if you want to consolidate common behavior in Hibernate classes. </para> </listitem> </itemizedlist> </sect2> </sect1> </chapter> Index: index.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/index.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** index.xml 27 Mar 2003 23:15:57 -0000 1.5 --- index.xml 3 Apr 2003 01:43:30 -0000 1.6 *************** *** 13,16 **** --- 13,17 ---- <!ENTITY examples SYSTEM "examples.xml"> <!ENTITY best-practices SYSTEM "best_practices.xml"> + <!ENTITY toolset-guide SYSTEM "toolset_guide.xml"> ]> *************** *** 45,48 **** --- 46,51 ---- &best-practices; + + &toolset-guide; </book> |
From: <one...@us...> - 2003-04-02 13:11:11
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv2791/hibernate/persister Modified Files: EntityPersister.java Log Message: fixed a problem where an (incorrect) SQL UPDATE was issued when update() was called on an object with no updateable properties Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/EntityPersister.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** EntityPersister.java 29 Mar 2003 04:08:48 -0000 1.22 --- EntityPersister.java 2 Apr 2003 13:10:36 -0000 1.23 *************** *** 81,85 **** private final Type[] subclassPropertyTypeClosure; private final Class[] subclassClosure; ! private final boolean hasColumns; private final int[] joinedFetch; --- 81,85 ---- private final Type[] subclassPropertyTypeClosure; private final Class[] subclassClosure; ! private final boolean hasUpdateableColumns; private final int[] joinedFetch; *************** *** 573,577 **** } ! if (!hasColumns) return; final PreparedStatement statement; --- 573,577 ---- } ! if (!hasUpdateableColumns) return; final PreparedStatement statement; *************** *** 682,686 **** colNames[j] = col.getName(); j++; ! foundColumn=true; } propertyColumnNames[i] = colNames; --- 682,686 ---- colNames[j] = col.getName(); j++; ! if ( prop.isUpdateable() ) foundColumn=true; } propertyColumnNames[i] = colNames; *************** *** 695,699 **** } ! hasColumns = foundColumn; ArrayList columns = new ArrayList(); --- 695,699 ---- } ! hasUpdateableColumns = foundColumn; ArrayList columns = new ArrayList(); |
From: <one...@us...> - 2003-04-02 13:10:50
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv2791/hibernate/test Modified Files: Baz.hbm.xml Container.hbm.xml FooBar.hbm.xml Glarch.hbm.xml MasterDetailTest.java Multi.hbm.xml ParentChildTest.java Added Files: W.java WZ.hbm.xml Z.java Log Message: fixed a problem where an (incorrect) SQL UPDATE was issued when update() was called on an object with no updateable properties --- NEW FILE: W.java --- package net.sf.hibernate.test; import java.util.Set; public class W { private long id; private Set zeds; /** * */ public W() { super(); // TODO Auto-generated constructor stub } /** * @return */ public long getId() { return id; } /** * @return */ public Set getZeds() { return zeds; } /** * @param l */ public void setId(long l) { id = l; } /** * @param set */ public void setZeds(Set set) { zeds = set; } } --- NEW FILE: WZ.hbm.xml --- <?xml version="1.0"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <class name="net.sf.hibernate.test.Z"> <id name="id" unsaved-value="0"> <generator class="hilo"/> </id> <many-to-one name="w" cascade="save-update" class="net.sf.hibernate.test.W" insert="true" update="false" not-null="true"/> </class> <class name="net.sf.hibernate.test.W" discriminator-value="0" proxy="net.sf.hibernate.test.Z"> <id name="id" unsaved-value="0"> <generator class="hilo"/> </id> <!--<set name="zeds" lazy="true"> <key column="w"/> <one-to-many class="net.sf.hibernate.test.Z"/> </set>--> </class> </hibernate-mapping> --- NEW FILE: Z.java --- package net.sf.hibernate.test; public class Z { private long id; private W w; /** * */ public Z() { super(); // TODO Auto-generated constructor stub } /** * @return */ public long getId() { return id; } /** * @return */ public W getW() { return w; } /** * @param l */ public void setId(long l) { id = l; } /** * @param w */ public void setW(W w) { this.w = w; } } Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Baz.hbm.xml 29 Mar 2003 07:36:22 -0000 1.14 --- Baz.hbm.xml 2 Apr 2003 13:10:37 -0000 1.15 *************** *** 99,103 **** <array name="fooArray" element-class="net.sf.hibernate.test.FooProxy" where="i<8"> ! <!--<jcs-cache usage="read-write"/>--> <key column="id_" /> <index column="i"/> --- 99,103 ---- <array name="fooArray" element-class="net.sf.hibernate.test.FooProxy" where="i<8"> ! <jcs-cache usage="read-write"/> <key column="id_" /> <index column="i"/> *************** *** 134,138 **** <list name="topComponents" table="topcomponents"> ! <!--<jcs-cache usage="read-write"/>--> <key column="id_"/> <index column="i"/> --- 134,138 ---- <list name="topComponents" table="topcomponents"> ! <jcs-cache usage="read-write"/> <key column="id_"/> <index column="i"/> Index: Container.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Container.hbm.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Container.hbm.xml 29 Mar 2003 07:36:22 -0000 1.7 --- Container.hbm.xml 2 Apr 2003 13:10:38 -0000 1.8 *************** *** 57,60 **** --- 57,61 ---- </bag> <bag name="lazyBag" inverse="true" lazy="true" table="LCCBAG" cascade="save-update"> + <!--jcs-cache usage="read-write"--> <key column="container_id"/> <many-to-many column="contained_id" class="net.sf.hibernate.test.Contained"/> Index: FooBar.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBar.hbm.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FooBar.hbm.xml 29 Mar 2003 07:36:22 -0000 1.11 --- FooBar.hbm.xml 2 Apr 2003 13:10:38 -0000 1.12 *************** *** 10,15 **** table="foos" proxy="net.sf.hibernate.test.FooProxy" ! discriminator-value="F" ! dynamic-update="true"> <jcs-cache usage="read-write"/> --- 10,14 ---- table="foos" proxy="net.sf.hibernate.test.FooProxy" ! discriminator-value="F"> <jcs-cache usage="read-write"/> Index: Glarch.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Glarch.hbm.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Glarch.hbm.xml 29 Mar 2003 07:36:22 -0000 1.10 --- Glarch.hbm.xml 2 Apr 2003 13:10:38 -0000 1.11 *************** *** 3,7 **** <hibernate-mapping> ! <class name="net.sf.hibernate.test.Glarch" table="glarchez" proxy="net.sf.hibernate.test.GlarchProxy"> <!--<jcs-cache usage="read-write"/>--> <id type="string" column="tha_key" length="32"> --- 3,10 ---- <hibernate-mapping> ! <class name="net.sf.hibernate.test.Glarch" ! table="glarchez" ! proxy="net.sf.hibernate.test.GlarchProxy" ! dynamic-update="true"> <!--<jcs-cache usage="read-write"/>--> <id type="string" column="tha_key" length="32"> Index: MasterDetailTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MasterDetailTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MasterDetailTest.java 8 Mar 2003 06:31:23 -0000 1.5 --- MasterDetailTest.java 2 Apr 2003 13:10:39 -0000 1.6 *************** *** 474,477 **** --- 474,496 ---- } + public void testNoUpdateManyToOne() throws Exception { + Session s = sessions.openSession(); + W w1 = new W(); + W w2 = new W(); + Z z = new Z(); + z.setW(w1); + s.save(z); + s.flush(); + z.setW(w2); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + s.update(z); + s.flush(); + s.connection().commit(); + s.close(); + } public static Test suite() throws Exception { *************** *** 482,486 **** "Category.hbm.xml", "Nameable.hbm.xml", ! "SingleSeveral.hbm.xml" } ); --- 501,506 ---- "Category.hbm.xml", "Nameable.hbm.xml", ! "SingleSeveral.hbm.xml", ! "WZ.hbm.xml" } ); Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Multi.hbm.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Multi.hbm.xml 29 Mar 2003 07:36:22 -0000 1.8 --- Multi.hbm.xml 2 Apr 2003 13:10:39 -0000 1.9 *************** *** 3,7 **** <hibernate-mapping> ! <class name="net.sf.hibernate.test.Simple" table="rootclass" dynamic-update="true"> <jcs-cache usage="read-write"/> <id type="long" column="id_" > --- 3,7 ---- <hibernate-mapping> ! <class name="net.sf.hibernate.test.Simple" table="rootclass"> <jcs-cache usage="read-write"/> <id type="long" column="id_" > *************** *** 43,47 **** </joined-subclass> ! <joined-subclass name="net.sf.hibernate.test.Multi" table="nonleafsubclass" dynamic-update="true"> <key column="sid"/> <property name="extraProp"/> --- 43,47 ---- </joined-subclass> ! <joined-subclass name="net.sf.hibernate.test.Multi" table="nonleafsubclass"> <key column="sid"/> <property name="extraProp"/> Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ParentChildTest.java 29 Mar 2003 07:36:22 -0000 1.8 --- ParentChildTest.java 2 Apr 2003 13:10:39 -0000 1.9 *************** *** 415,418 **** --- 415,425 ---- t = s.beginTransaction(); c = (Container) s.find("from c in class ContainerX").get(0); + c.getLazyBag().size(); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + c = (Container) s.find("from c in class ContainerX").get(0); Contained c3 = new Contained(); //c.getBag().add(c3); |
From: <one...@us...> - 2003-04-02 02:49:11
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id In directory sc8-pr-cvs1:/tmp/cvs-serv30148/hibernate/id Modified Files: SequenceHiLoGenerator.java TableHiLoGenerator.java Log Message: fixed bugs in hi/lo generators (Maarten Coene) Index: SequenceHiLoGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id/SequenceHiLoGenerator.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SequenceHiLoGenerator.java 25 Mar 2003 13:49:35 -0000 1.7 --- SequenceHiLoGenerator.java 2 Apr 2003 02:49:07 -0000 1.8 *************** *** 36,40 **** private static final Log log = LogFactory.getLog(SequenceHiLoGenerator.class); ! private int maxLoValue; private int lo; private long hi; --- 36,40 ---- private static final Log log = LogFactory.getLog(SequenceHiLoGenerator.class); ! private int maxLo; private int lo; private long hi; *************** *** 43,47 **** public void configure(Type type, Properties params, Dialect d) throws MappingException { super.configure(type, params, d); ! lo = maxLoValue = PropertiesHelper.getInt(MAX_LO, params, 9); returnClass = type.getReturnedClass(); } --- 43,48 ---- public void configure(Type type, Properties params, Dialect d) throws MappingException { super.configure(type, params, d); ! maxLo = PropertiesHelper.getInt(MAX_LO, params, 9); ! lo = maxLo + 1; // so we "clock over" on the first invocation returnClass = type.getReturnedClass(); } *************** *** 49,56 **** public synchronized Serializable generate(SessionImplementor session, Object obj) throws SQLException, HibernateException { ! if ( lo>maxLoValue ) { long hival = ( (Number) super.generate(session, obj) ).longValue(); lo = 1; ! hi = hival * ( maxLoValue+1 ); log.debug("new hi value: " + hival); } --- 50,57 ---- public synchronized Serializable generate(SessionImplementor session, Object obj) throws SQLException, HibernateException { ! if ( lo>maxLo ) { long hival = ( (Number) super.generate(session, obj) ).longValue(); lo = 1; ! hi = hival * ( maxLo+1 ); log.debug("new hi value: " + hival); } Index: TableHiLoGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/id/TableHiLoGenerator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TableHiLoGenerator.java 25 Mar 2003 13:49:43 -0000 1.4 --- TableHiLoGenerator.java 2 Apr 2003 02:49:07 -0000 1.5 *************** *** 48,52 **** public void configure(Type type, Properties params, Dialect d) { super.configure(type, params, d); ! lo = maxLo = PropertiesHelper.getInt(MAX_LO, params, Short.MAX_VALUE); returnClass = type.getReturnedClass(); } --- 48,53 ---- public void configure(Type type, Properties params, Dialect d) { super.configure(type, params, d); ! maxLo = PropertiesHelper.getInt(MAX_LO, params, Short.MAX_VALUE); ! lo = maxLo + 1; // so we "clock over" on the first invocation returnClass = type.getReturnedClass(); } |
From: <one...@us...> - 2003-04-02 01:12:27
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv28160/hibernate/engine Modified Files: SessionImplementor.java Log Message: * fixed a theoretical problem with caching and queued adds * fixed a real problem with sorted sets * re-enabled two-phase loading for sets Index: SessionImplementor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine/SessionImplementor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SessionImplementor.java 29 Mar 2003 04:08:46 -0000 1.9 --- SessionImplementor.java 2 Apr 2003 01:12:20 -0000 1.10 *************** *** 63,69 **** public void initialize(PersistentCollection collection, boolean writing) throws HibernateException, SQLException; /** ! * Is this the readonly end of a bidirectional association? */ ! public boolean isCollectionReadOnly(PersistentCollection collection); /** --- 63,69 ---- public void initialize(PersistentCollection collection, boolean writing) throws HibernateException, SQLException; /** ! * Is this the "inverse" end of a bidirectional association? */ ! public boolean isInverseCollection(PersistentCollection collection); /** |
From: <one...@us...> - 2003-04-02 01:06:57
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv25747/hibernate/loader Modified Files: CollectionLoader.java Loader.java OneToManyLoader.java Log Message: * fixed a theoretical problem with caching and queued adds * fixed a real problem with sorted sets * re-enabled two-phase loading for sets Index: CollectionLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/CollectionLoader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CollectionLoader.java 23 Feb 2003 07:22:11 -0000 1.10 --- CollectionLoader.java 2 Apr 2003 01:06:53 -0000 1.11 *************** *** 26,30 **** private final CollectionPersister collectionPersister; private final Type idType; - private final boolean allowTwoPhaseLoad; public CollectionLoader(CollectionPersister persister, SessionFactoryImplementor session) throws MappingException { --- 26,29 ---- *************** *** 32,37 **** super( session.getDialect() ); - allowTwoPhaseLoad = !persister.isSet(); - idType = persister.getKeyType(); --- 31,34 ---- *************** *** 78,85 **** public void initialize(Serializable id, PersistentCollection collection, Object owner, SessionImplementor session) throws SQLException, HibernateException { loadCollection(session, id, idType, owner, collection); - } - - protected boolean allowTwoPhaseLoad() { - return allowTwoPhaseLoad; } --- 75,78 ---- Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Loader.java 20 Mar 2003 13:59:09 -0000 1.15 --- Loader.java 2 Apr 2003 01:06:53 -0000 1.16 *************** *** 66,71 **** } /** ! * Are we allowed to do two-phase loading? (we aren't for some special cases ! * like sets of entities ... actually only that one special case) */ protected boolean allowTwoPhaseLoad() { --- 66,71 ---- } /** ! * Are we allowed to do two-phase loading? ! * @deprecated we always do two-phase loading now */ protected boolean allowTwoPhaseLoad() { *************** *** 119,122 **** --- 119,124 ---- final ResultSet rs = getResultSet(st, namedParams, selection, session); + if (collection) optionalCollection.beginRead(); + try { *************** *** 178,181 **** --- 180,185 ---- while ( iter.hasNext() ) session.initializeEntity( iter.next() ); } + + if (collection) optionalCollection.endRead(); return results; Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** OneToManyLoader.java 23 Feb 2003 07:22:11 -0000 1.11 --- OneToManyLoader.java 2 Apr 2003 01:06:53 -0000 1.12 *************** *** 27,31 **** private final CollectionPersister collectionPersister; private final Type idType; - private final boolean allowTwoPhaseLoad; public OneToManyLoader(CollectionPersister collPersister, SessionFactoryImplementor session) throws MappingException { --- 27,30 ---- *************** *** 33,38 **** super( session.getDialect() ); - allowTwoPhaseLoad = !collPersister.isSet(); - collectionPersister = collPersister; --- 32,35 ---- *************** *** 92,99 **** public void initialize(Serializable id, PersistentCollection collection, Object owner, SessionImplementor session) throws SQLException, HibernateException { loadCollection(session, id, idType, owner, collection); - } - - protected boolean allowTwoPhaseLoad() { - return allowTwoPhaseLoad; } --- 89,92 ---- |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv25747/hibernate/collection Modified Files: ArrayHolder.java CollectionPersister.java PersistentCollection.java Set.java Log Message: * fixed a theoretical problem with caching and queued adds * fixed a real problem with sorted sets * re-enabled two-phase loading for sets Index: ArrayHolder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/ArrayHolder.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ArrayHolder.java 6 Mar 2003 11:12:08 -0000 1.10 --- ArrayHolder.java 2 Apr 2003 01:06:52 -0000 1.11 *************** *** 29,33 **** //just to help out during the load (ugly, i know) private transient Class elementClass; ! private transient java.util.List temp; public ArrayHolder(SessionImplementor session, Object array) { --- 29,33 ---- //just to help out during the load (ugly, i know) private transient Class elementClass; ! private transient java.util.List tempList; public ArrayHolder(SessionImplementor session, Object array) { *************** *** 38,45 **** public Serializable snapshot(CollectionPersister persister) throws HibernateException { ! int length = (array==null) ? temp.size() : Array.getLength(array); Serializable result = (Serializable) Array.newInstance( persister.getElementClass(), length ); for ( int i=0; i<length; i++ ) { ! Object elt = (array==null) ? temp.get(i) : Array.get(array, i); try { Array.set( result, i, persister.getElementType().deepCopy(elt) ); --- 38,45 ---- public Serializable snapshot(CollectionPersister persister) throws HibernateException { ! int length = /*(array==null) ? tempList.size() :*/ Array.getLength(array); Serializable result = (Serializable) Array.newInstance( persister.getElementClass(), length ); for ( int i=0; i<length; i++ ) { ! Object elt = /*(array==null) ? tempList.get(i) :*/ Array.get(array, i); try { Array.set( result, i, persister.getElementType().deepCopy(elt) ); *************** *** 87,91 **** */ public Iterator elements() { ! if (array==null) return temp.iterator(); int length = Array.getLength(array); java.util.List list = new ArrayList(length); --- 87,91 ---- */ public Iterator elements() { ! //if (array==null) return tempList.iterator(); int length = Array.getLength(array); java.util.List list = new ArrayList(length); *************** *** 115,126 **** throws HibernateException, SQLException { ! // relys on the fact that elements are returned sorted by index! Object element = persister.readElement(rs, owner, session); int index = ( (Integer) persister.readIndex(rs, session) ).intValue(); ! for ( int i = temp.size(); i<=index; i++) { ! temp.add(i, null); } ! temp.set(index, element); return element; } --- 115,126 ---- throws HibernateException, SQLException { ! // relies on the fact that elements are returned sorted by index! (obsolete comment, I think?) Object element = persister.readElement(rs, owner, session); int index = ( (Integer) persister.readIndex(rs, session) ).intValue(); ! for ( int i = tempList.size(); i<=index; i++) { ! tempList.add(i, null); } ! tempList.set(index, element); return element; } *************** *** 146,167 **** } //Arrays have to do things a bit differently. public Object getInitialValue(boolean lazy) throws SQLException, HibernateException { - - temp = new ArrayList(); super.getInitialValue(false); - array = Array.newInstance( elementClass, temp.size() ); - for ( int i=0; i<temp.size(); i++) { - Array.set(array, i, temp.get(i) ); - } - session.addArrayHolder(this); - temp=null; return array; } public void beforeInitialize(CollectionPersister persister) { ! //if (temp==null) throw new UnsupportedOperationException("Can't lazily initialize arrays"); } --- 146,170 ---- } + public void beginRead() { + tempList = new ArrayList(); + } + public void endRead() { + array = Array.newInstance( elementClass, tempList.size() ); + for ( int i=0; i<tempList.size(); i++) { + Array.set(array, i, tempList.get(i) ); + } + tempList=null; + } + //Arrays have to do things a bit differently. public Object getInitialValue(boolean lazy) throws SQLException, HibernateException { super.getInitialValue(false); session.addArrayHolder(this); return array; } public void beforeInitialize(CollectionPersister persister) { ! //if (tempList==null) throw new UnsupportedOperationException("Can't lazily initialize arrays"); } *************** *** 185,194 **** public Serializable disassemble(CollectionPersister persister) throws HibernateException { ! ! int length = temp.size(); Serializable[] result = new Serializable[length]; for ( int i=0; i<length; i++ ) { ! result[i] = persister.getElementType().disassemble( temp.get(i), session ); } return result; --- 188,203 ---- public Serializable disassemble(CollectionPersister persister) throws HibernateException { ! int length = Array.getLength(array); Serializable[] result = new Serializable[length]; for ( int i=0; i<length; i++ ) { ! result[i] = persister.getElementType().disassemble( Array.get(array,i), session ); } + + /*int length = tempList.size(); + Serializable[] result = new Serializable[length]; + for ( int i=0; i<length; i++ ) { + result[i] = persister.getElementType().disassemble( tempList.get(i), session ); + }*/ + return result; Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/CollectionPersister.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CollectionPersister.java 16 Mar 2003 01:45:52 -0000 1.16 --- CollectionPersister.java 2 Apr 2003 01:06:52 -0000 1.17 *************** *** 61,65 **** private final boolean hasOrder; private final boolean hasWhere; ! private final boolean isSet; private final Type keyType; private final Type indexType; --- 61,65 ---- private final boolean hasOrder; private final boolean hasWhere; ! //private final boolean isSet; private final Type keyType; private final Type indexType; *************** *** 86,89 **** --- 86,90 ---- private final int enableJoinedFetch; private final Class ownerClass; + //private final boolean isSorted; private final CollectionInitializer loader; *************** *** 119,123 **** } ! isSet = collection.isSet(); isOneToMany = collection.isOneToMany(); primitiveArray = collection.isPrimitiveArray(); --- 120,125 ---- } ! //isSet = collection.isSet(); ! //isSorted = collection.isSorted(); isOneToMany = collection.isOneToMany(); primitiveArray = collection.isPrimitiveArray(); *************** *** 689,699 **** } - public boolean isSet() { - return isSet; - } - public Class getOwnerClass() { return ownerClass; } } --- 691,705 ---- } public Class getOwnerClass() { return ownerClass; } + + /*public boolean isSet() { + return isSet; + } + + public boolean isSorted() { + return isSorted; + }*/ } Index: PersistentCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/PersistentCollection.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PersistentCollection.java 16 Mar 2003 01:45:52 -0000 1.10 --- PersistentCollection.java 2 Apr 2003 01:06:52 -0000 1.11 *************** *** 61,67 **** } protected final void write() { initialize(true); ! if ( session!=null && session.isOpen() ) { session.dirty(this); } --- 61,71 ---- } + private final boolean isConnectedToSession() { + return session!=null && session.isOpen(); + } + protected final void write() { initialize(true); ! if ( isConnectedToSession() ) { session.dirty(this); } *************** *** 72,76 **** private boolean mayQueueAdd() { ! return !initialized && session!=null && session.isOpen() && session.isCollectionReadOnly(this); } --- 76,82 ---- private boolean mayQueueAdd() { ! return !initialized && ! isConnectedToSession() && ! session.isInverseCollection(this); } *************** *** 79,82 **** --- 85,89 ---- if (additions==null) additions = new ArrayList(10); additions.add(element); + session.dirty(this); //needed so that we remove this collection from the JCS cache return true; } *************** *** 119,125 **** } public final void initialize(boolean writing) { if (!initialized) { ! if ( session!=null && session.isOpen() ) { try { session.initialize(this, writing); --- 126,140 ---- } + public void beginRead() { + // override on some subclasses + } + + public void endRead() { + //override on some subclasses + } + public final void initialize(boolean writing) { if (!initialized) { ! if ( isConnectedToSession() ) { try { session.initialize(this, writing); *************** *** 149,153 **** } else { ! if ( (this.session!=null) && this.session.isOpen() ) { throw new HibernateException("Illegal attempt to associate a collection with two open sessions"); } --- 164,168 ---- } else { ! if ( isConnectedToSession() ) { throw new HibernateException("Illegal attempt to associate a collection with two open sessions"); } Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Set.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Set.java 6 Mar 2003 11:12:12 -0000 1.9 --- Set.java 2 Apr 2003 01:06:53 -0000 1.10 *************** *** 26,29 **** --- 26,30 ---- public class Set extends ODMGCollection implements java.util.Set, DSet { protected java.util.Set set; + private transient java.util.List tempList; public Serializable snapshot(CollectionPersister persister) throws HibernateException { *************** *** 228,233 **** public Object readFrom(ResultSet rs, CollectionPersister persister, Object owner) throws HibernateException, SQLException { Object element = persister.readElement(rs, owner, session); ! set.add(element); return element; } --- 229,243 ---- public Object readFrom(ResultSet rs, CollectionPersister persister, Object owner) throws HibernateException, SQLException { Object element = persister.readElement(rs, owner, session); ! tempList.add(element); return element; + } + + public void beginRead() { + tempList = new ArrayList(); + } + + public void endRead() { + set.addAll(tempList); + tempList = null; } |
From: <one...@us...> - 2003-04-02 01:06:55
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv25747/hibernate/impl Modified Files: ScheduledCollectionUpdate.java SessionFactoryImpl.java SessionImpl.java Log Message: * fixed a theoretical problem with caching and queued adds * fixed a real problem with sorted sets * re-enabled two-phase loading for sets Index: ScheduledCollectionUpdate.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/ScheduledCollectionUpdate.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScheduledCollectionUpdate.java 2 Feb 2003 04:19:51 -0000 1.5 --- ScheduledCollectionUpdate.java 2 Apr 2003 01:06:51 -0000 1.6 *************** *** 5,8 **** --- 5,9 ---- import java.sql.SQLException; + import net.sf.hibernate.AssertionFailure; import net.sf.hibernate.HibernateException; import net.sf.hibernate.collection.CollectionPersister; *************** *** 21,25 **** public void execute() throws SQLException, HibernateException { persister.softlock(id); ! if ( collection.empty() ) { persister.remove(id, session); } --- 22,30 ---- public void execute() throws SQLException, HibernateException { persister.softlock(id); ! if ( !collection.wasInitialized() ) { ! if ( !collection.hasQueuedAdds() ) throw new AssertionFailure("bug processing queued adds"); ! //do nothing - we only need to notify the cache... ! } ! else if ( collection.empty() ) { persister.remove(id, session); } Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SessionFactoryImpl.java 29 Mar 2003 04:08:47 -0000 1.15 --- SessionFactoryImpl.java 2 Apr 2003 01:06:52 -0000 1.16 *************** *** 22,26 **** import java.util.Map; import java.util.Properties; - import java.util.Collections; import javax.naming.NamingException; --- 22,25 ---- Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** SessionImpl.java 29 Mar 2003 04:08:47 -0000 1.29 --- SessionImpl.java 2 Apr 2003 01:06:52 -0000 1.30 *************** *** 271,275 **** // if the collection is initialized and it was previously persistent // initialize the dirty flag ! dirty = initialized && loadedPersister!=null && isDirty(collection); if ( log.isDebugEnabled() && dirty && loadedPersister!=null ) log.debug( --- 271,276 ---- // if the collection is initialized and it was previously persistent // initialize the dirty flag ! dirty = ( initialized && loadedPersister!=null && isDirty(collection) ) || ! ( !initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache if ( log.isDebugEnabled() && dirty && loadedPersister!=null ) log.debug( *************** *** 2470,2474 **** } ! else if( entry.dirty ) { // else if it's elements changed entry.doupdate = true; } --- 2471,2475 ---- } ! else if (entry.dirty) { // else if it's elements changed entry.doupdate = true; } *************** *** 2503,2507 **** CollectionEntry entry = getCollectionEntry(coll); ! return entry.initialized && ( entry.dirty || coll.hasQueuedAdds() ); } --- 2504,2508 ---- CollectionEntry entry = getCollectionEntry(coll); ! return entry.initialized && entry.dirty; //( entry.dirty || coll.hasQueuedAdds() ); } *************** *** 2588,2592 **** } ! public boolean isCollectionReadOnly(PersistentCollection collection) { CollectionEntry ce = getCollectionEntry(collection); return ce!=null && ce.loadedPersister.isInverse(); --- 2589,2593 ---- } ! public boolean isInverseCollection(PersistentCollection collection) { CollectionEntry ce = getCollectionEntry(collection); return ce!=null && ce.loadedPersister.isInverse(); |
From: <db...@us...> - 2003-03-31 06:45:17
|
Update of /cvsroot/hibernate/Hibernate2 In directory sc8-pr-cvs1:/tmp/cvs-serv1335 Modified Files: build.xml Log Message: removed ra.xml from the .jar as it was confusing JBoss Index: build.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/build.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** build.xml 29 Mar 2003 10:13:33 -0000 1.13 --- build.xml 31 Mar 2003 06:45:12 -0000 1.14 *************** *** 61,64 **** --- 61,65 ---- <exclude name="**/*.ccf"/> <exclude name="**/*.cfg.xml"/> + <exclude name="META-INF/ra.xml"/> </patternset> *************** *** 149,153 **** <include name="${dist.dir}/${jar.name}.jar" /> </fileset> ! <fileset dir="${build.dir}"> <include name="META-INF/ra.xml" /> </fileset> --- 150,154 ---- <include name="${dist.dir}/${jar.name}.jar" /> </fileset> ! <fileset dir="${src.dir}"> <include name="META-INF/ra.xml" /> </fileset> |
From: <db...@us...> - 2003-03-31 06:35:35
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv29715/doc/reference/src Modified Files: query_language.xml Log Message: fixed broken id on added section Index: query_language.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/query_language.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** query_language.xml 31 Mar 2003 02:25:30 -0000 1.8 --- query_language.xml 31 Mar 2003 06:35:28 -0000 1.9 *************** *** 635,639 **** </sect1> ! <sect1 id="query-language-s9"> <title>Examples</title> --- 635,639 ---- </sect1> ! <sect1 id="query-language-s10"> <title>Examples</title> |
From: <one...@us...> - 2003-03-31 02:25:33
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv858/reference/src Modified Files: query_language.xml Log Message: example queries Index: query_language.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/query_language.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** query_language.xml 30 Mar 2003 06:40:17 -0000 1.7 --- query_language.xml 31 Mar 2003 02:25:30 -0000 1.8 *************** *** 307,314 **** <programlisting><![CDATA[from bank.Person person ! where person.id.country = 'AU' and person.id.medicareNumber = 123456 from bank.Account account ! where account.owner.id.country = 'AU' and account.owner.id.medicareNumber = 123456]]></programlisting> <para> --- 307,316 ---- <programlisting><![CDATA[from bank.Person person ! where person.id.country = 'AU' ! and person.id.medicareNumber = 123456 from bank.Account account ! where account.owner.id.country = 'AU' ! and account.owner.id.medicareNumber = 123456]]></programlisting> <para> *************** *** 589,596 **** </para> ! <programlisting><![CDATA[select cat.color, sum(cat.weight), count(cat) from eg.Cat cat group by cat.color ! select foo.id, avg( elements(foo.names) ), max( indices(foo.names) ) from eg.Foo foo group by foo.id]]></programlisting> --- 591,600 ---- </para> ! <programlisting><![CDATA[select cat.color, sum(cat.weight), count(cat) ! from eg.Cat cat group by cat.color ! select foo.id, avg( elements(foo.names) ), max( indices(foo.names) ) ! from eg.Foo foo group by foo.id]]></programlisting> *************** *** 600,605 **** <para>A <literal>having</literal> clause is also allowed.</para> ! <programlisting><![CDATA[select cat.color, sum(cat.weight), count(cat) from eg.Cat cat ! group by cat.color having cat.color in (eg.Color.TABBY, eg.Color.BLACK)]]></programlisting> </sect1> --- 604,611 ---- <para>A <literal>having</literal> clause is also allowed.</para> ! <programlisting><![CDATA[select cat.color, sum(cat.weight), count(cat) ! from eg.Cat cat ! group by cat.color ! having cat.color in (eg.Color.TABBY, eg.Color.BLACK)]]></programlisting> </sect1> *************** *** 628,631 **** --- 634,714 ---- </sect1> + + <sect1 id="query-language-s9"> + <title>Examples</title> + + <para> + Hibernate queries can be quite powerful and complex. In fact, the power of the query language + is one of Hibernate's main selling points. Here are some example queries very similar to queries + that I used on a recent project. + </para> + + <para> + This query counts the number of payments in each status, excluding all payments in the + <literal>AWAITING_APPROVAL</literal> status where the most recent status change was made by the + current user. It translates to an SQL query with two inner joins and a subselect against the + <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal> and + <literal>PAYMENT_STATUS_CHANGE</literal> tables. + </para> + + <programlisting><![CDATA[select count(payment), status.name + from Payment as payment + join payment.currentStatus as status + join payment.statusChanges as statusChange + where payment.status.name <> PaymentStatus.AWAITING_APPROVAL + or ( + statusChange.timeStamp = ( + select max(change.timeStamp) + from PaymentStatusChange change + where change.payment = payment + ) + and statusChange.user <> :currentUser + ) + group by status.name, status.sortOrder + order by status.sortOrder]]></programlisting> + + <para> + If I would have mapped the <literal>statusChanges</literal> collection as a list, instead of a set, + the query would have been much simpler to write. + </para> + + <programlisting><![CDATA[select count(payment), status.name + from Payment as payment + join payment.currentStatus as status + where payment.status.name <> PaymentStatus.AWAITING_APPROVAL + or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :currentUser + group by status.name, status.sortOrder + order by status.sortOrder]]></programlisting> + + <para> + The next query uses the MS SQL Server <literal>isNull()</literal> function to return all + the accounts and unpaid payments for the organization to which the current user belongs. + It translates to an SQL query with three inner joins, an outer join and a subselect against + the <literal>ACCOUNT</literal>, <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal>, + <literal>ACCOUNT_TYPE</literal>, <literal>ORGANIZATION</literal> and + <literal>ORG_USER</literal> tables. + </para> + + <programlisting><![CDATA[select account, payment + from Account as account + left outer join account.payments as payment + where :currentUser in elements(account.holder.users) + and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID) + order by account.type.sortOrder, account.accountNumber, payment.dueDate]]></programlisting> + + <para> + For some databases, we would need to do away with the subselect. + </para> + + <programlisting><![CDATA[select account, payment + from Account as account + join account.holder.users as user + left outer join account.payments as payment + where :currentUser = user + and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID) + order by account.type.sortOrder, account.accountNumber, payment.dueDate]]></programlisting> + + </sect1> + </chapter> |
From: <one...@us...> - 2003-03-30 06:40:21
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv18042/reference/src Modified Files: basic_or_mapping.xml query_language.xml Log Message: minor changes Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** basic_or_mapping.xml 29 Mar 2003 13:31:22 -0000 1.11 --- basic_or_mapping.xml 30 Mar 2003 06:40:17 -0000 1.12 *************** *** 1481,1486 **** <para> ! The old <literal>object</literal> type from Hibernate 1.2 is still supported, but is ! semi-deprecated. </para> --- 1481,1486 ---- <para> ! The old <literal>object</literal> type that filled a similar role in Hibernate 1.2 is still ! supported, but is now semi-deprecated. </para> Index: query_language.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/query_language.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** query_language.xml 3 Mar 2003 01:07:03 -0000 1.6 --- query_language.xml 30 Mar 2003 06:40:17 -0000 1.7 *************** *** 609,615 **** <para> ! For databases that support subselects, Hibernate supports subqueries within queries. A subquery must ! be surrounded by parentheses (often by an SQL aggregate function call). Even correlated subqueries ! (subqueries that refer to an alias in the outer query) are allowed. </para> --- 609,615 ---- <para> ! For databases that support subselects, Hibernate supports subqueries within queries. A subquery must ! be surrounded by parentheses (often by an SQL aggregate function call). Even correlated subqueries ! (subqueries that refer to an alias in the outer query) are allowed. </para> *************** *** 618,625 **** from eg.DomesticCat cat where cat.name = ! some( select list.name from eg.NameList list ) from eg.Cat cat where not exists ! ( from eg.Cat mate where mate.mate = cat )]]></programlisting> </sect1> --- 618,629 ---- from eg.DomesticCat cat where cat.name = ! some( select name.nickName from eg.Name name ) from eg.Cat cat where not exists ! ( from eg.Cat mate where mate.mate = cat ) ! ! from eg.DomesticCat cat where cat.name not in ! ( select name.nickName from eg.Name name )]]></programlisting> ! </sect1> |
From: <one...@us...> - 2003-03-29 23:44:52
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv29396/src/net/sf/hibernate Modified Files: HibernateException.java Log Message: fixed JavaDoc to reflect current usage Index: HibernateException.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/HibernateException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HibernateException.java 5 Jan 2003 02:11:19 -0000 1.3 --- HibernateException.java 29 Mar 2003 23:44:49 -0000 1.4 *************** *** 5,11 **** /** ! * Any exception that occurs in the O-R persistence layer. ! * (As opposed to exceptions that occur in DB or JDBC driver ! * which are always left as SQLExceptions.) */ --- 5,13 ---- /** ! * Any exception that occurs inside the persistence layer ! * or JDBC driver. <tt>SQLException</tt>s are always wrapped ! * by instances of <tt>JDBCException</tt>. ! * ! * @see JDBCException */ |
From: <one...@us...> - 2003-03-29 13:31:28
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv6769/reference/src Modified Files: advanced_or_mapping.xml basic_or_mapping.xml Log Message: minor changes Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** advanced_or_mapping.xml 29 Mar 2003 09:51:27 -0000 1.12 --- advanced_or_mapping.xml 29 Mar 2003 13:31:22 -0000 1.13 *************** *** 48,53 **** </para> ! <programlisting><![CDATA[ ! Cat cat = new DomesticCat(); Cat kitten = new DomesticCat(); .... --- 48,52 ---- </para> ! <programlisting><![CDATA[Cat cat = new DomesticCat(); Cat kitten = new DomesticCat(); .... *************** *** 56,59 **** --- 55,59 ---- cat.setKittens(kittens); session.save(cat); + kittens = cat.getKittens(); //Okay, kittens collection is a Set (HashSet) cat.getKittens(); //Error!]]></programlisting> Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** basic_or_mapping.xml 29 Mar 2003 09:51:27 -0000 1.10 --- basic_or_mapping.xml 29 Mar 2003 13:31:22 -0000 1.11 *************** *** 250,254 **** <para> Mapped classes <emphasis>must</emphasis> declare the primary key column of the database ! table. Some classes may also have a JavaBeans-style property holding the unique identifier of an instance. The <literal><id></literal> element defines the mapping from that property to the primary key column. --- 250,254 ---- <para> Mapped classes <emphasis>must</emphasis> declare the primary key column of the database ! table. Most classes will also have a JavaBeans-style property holding the unique identifier of an instance. The <literal><id></literal> element defines the mapping from that property to the primary key column. *************** *** 289,293 **** <callout arearefs="id4"> <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 --- 289,293 ---- <callout arearefs="id4"> <para> ! <literal>unsaved-value</literal> (optional - defaults to <literal>null</literal>): An identifier property value that indicates that an instance is newly instantiated (unsaved), distinguishing it from transient instances that were saved or loaded *************** *** 304,320 **** <para> ! The <literal>unsaved-value</literal> attribute is required if (only if) you wish to use ! the <literal>Session.update()</literal> functionality. </para> <para> The required <literal><generator></literal> child element names a Java class used to generate unique identifiers for instances of the persistent class. If any parameters ! are required to initialize the ID generator, they are passed using the ! <literal><param></literal> element. eg: </para> ! <programlisting><![CDATA[<id name="id" type="long" column="uid" unsaved-value="null"> ! <generator class="net.sf.hibernate.id.HiLoGenerator"> <param name="table">uid_table</param> <param name="column">next_hi_value_column</param> --- 304,328 ---- <para> ! The <literal>unsaved-value</literal> attribute is important! If the identfier property of your ! class does not default to <literal>null</literal>, then you should specify the actual default. </para> + <para> + There is an alternative <literal><composite-id></literal> declaration to allow access to + legacy data with composite keys. We strongly discourage its use for anything else. + </para> + + <sect3 id="or-mapping-s1-4--generator"> + <title>generator</title> + <para> The required <literal><generator></literal> child element names a Java class used to generate unique identifiers for instances of the persistent class. If any parameters ! are required to configure or initialize the generator instance, they are passed using the ! <literal><param></literal> element. </para> ! <programlisting><![CDATA[<id name="id" type="long" column="uid" unsaved-value="0"> ! <generator class="net.sf.hibernate.id.TableHiLoGenerator"> <param name="table">uid_table</param> <param name="column">next_hi_value_column</param> *************** *** 323,330 **** <para> ! ID generators implement the interface <literal>net.sf.hibernate.id.IdentifierGenerator</literal>. This is a very simple interface; some applications may choose to provide their own specialized ! implementations. However, Hibernate provides a range of built-in implementations. ! There are shortcut names for the built-in ID generators: <variablelist> --- 331,338 ---- <para> ! All generators implement the interface <literal>net.sf.hibernate.id.IdentifierGenerator</literal>. This is a very simple interface; some applications may choose to provide their own specialized ! implementations. However, Hibernate provides a range of built-in implementations. There are shortcut ! names for the built-in generators: <variablelist> *************** *** 365,372 **** uses a hi/lo algorithm to efficiently generate identifiers of type <literal>long</literal>, <literal>short</literal> or <literal>int</literal>, ! given a table and column (by default "hibernate_unique_key" and "next" ! respectively) as a source of hi values. The hi/lo algorithm generates identifiers ! that are unique only for a particular database. <emphasis>Do not use this generator ! with connections enlisted with JTA or with a user-supplied connection.</emphasis> </para> </listitem> --- 373,381 ---- uses a hi/lo algorithm to efficiently generate identifiers of type <literal>long</literal>, <literal>short</literal> or <literal>int</literal>, ! given a table and column (by default <literal>hibernate_unique_key</literal> and ! <literal>next</literal> respectively) as a source of hi values. The hi/lo algorithm ! generates identifiers that are unique only for a particular database. <emphasis>Do not ! use this generator with connections enlisted with JTA or with a user-supplied ! connection.</emphasis> </para> </listitem> *************** *** 376,381 **** <listitem> <para> ! uses a hi/lo algorithm to efficiently generate identifiers of ! type <literal>long</literal>, <literal>short</literal> or <literal>int</literal>, given a named database sequence. </para> --- 385,390 ---- <listitem> <para> ! uses a hi/lo algorithm to efficiently generate identifiers of type ! <literal>long</literal>, <literal>short</literal> or <literal>int</literal>, given a named database sequence. </para> *************** *** 423,427 **** </para> ! <para> The UUIDs contain: IP address, startup time of the JVM (accurate to a quarter --- 432,455 ---- </para> ! </sect3> ! ! <sect3 id="or-mapping-s1-4-hilo"> ! <title>Hi/Lo Algorithm</title> ! <para> ! The <literal>hilo</literal> and <literal>seqhilo</literal> generators provide two alternate ! implementations of the hi/lo algorithm, a favorite approach to identifier generation. The ! first implementation requires a "special" database table to hold the next available "hi" value. ! The second uses an Oracle-style sequence (where supported). ! </para> ! <para> ! Unfortunately, you can't use <literal>hilo</literal> when supplying your own <literal>Connection</literal> ! to Hibernate, or when Hibernate is using an application server datasource to obtain connections ! enlisted with JTA. Hibernate must be able to fetch the "hi" value in a new transaction. A standard ! approach in an EJB environment is to implement the hi/lo algorithm using a stateless session bean. ! </para> ! </sect3> ! ! <sect3 id="or-mapping-s1-4-uuid"> ! <title>UUID Algorithm</title> <para> The UUIDs contain: IP address, startup time of the JVM (accurate to a quarter *************** *** 430,434 **** --- 458,470 ---- the best we can do without using JNI. </para> + + <para> + Don't try to use <literal>uuid.string</literal> in PostgreSQL. + </para> + + </sect3> + <sect3 id="or-mapping-s1-4-sequences"> + <title>Identity Columns and Sequences</title> <para> For databases which support identity columns (DB2, MySQL, Sybase, MS SQL), you *************** *** 436,440 **** sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you may use <literal>sequence</literal> style key generation. Both these strategies require ! two SQL queries to insert a new object. eg. </para> --- 472,476 ---- sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you may use <literal>sequence</literal> style key generation. Both these strategies require ! two SQL queries to insert a new object. </para> *************** *** 448,472 **** <generator class="native"/> </id>]]></programlisting> ! <para> If you want the application to assign identifiers (as opposed to having Hibernate generate them), you may use the <literal>assigned</literal> generator. This special generator will use the identifier value already assigned to the ! object's identifier property. We hope you won't use this feature to assign keys ! with business meaning (almost always a terrible design decision). ! </para> ! ! <para> ! Don't try to use <literal>uuid.string</literal> in PostgreSQL. ! Don't try to use <literal>hilo</literal> when supplying your own ! <literal>Connection</literal> to Hibernate, or when Hibernate is ! using an application server datasource to obtain connections enlisted with JTA. ! </para> ! ! <para> ! There is an alternative <literal><composite-id></literal> ! declaration to allow access to legacy data with composite keys. We strongly ! discourage its use for anything else. </para> </sect2> --- 484,508 ---- <generator class="native"/> </id>]]></programlisting> ! ! <para> ! For cross-platform development, the <literal>native</literal> strategy will ! choose from the <literal>identity</literal>, <literal>sequence</literal> and ! <literal>hilo</literal> strategies, dependant upon the capabalities of the ! underlying database. ! </para> ! ! </sect3> ! ! <sect3 id="or-mapping-s1-4-assigned"> ! <title>Assigned Identifiers</title> <para> If you want the application to assign identifiers (as opposed to having Hibernate generate them), you may use the <literal>assigned</literal> generator. This special generator will use the identifier value already assigned to the ! object's identifier property. Be very careful when using this feature to assign ! keys with business meaning (almost always a terrible design decision). </para> + </sect3> + </sect2> |