You can subscribe to this list here.
2002 |
Jan
(2) |
Feb
(157) |
Mar
(111) |
Apr
(61) |
May
(68) |
Jun
(45) |
Jul
(101) |
Aug
(132) |
Sep
(148) |
Oct
(227) |
Nov
(141) |
Dec
(285) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(518) |
Feb
(462) |
Mar
(390) |
Apr
(488) |
May
(321) |
Jun
(336) |
Jul
(268) |
Aug
(374) |
Sep
(211) |
Oct
(246) |
Nov
(239) |
Dec
(173) |
2004 |
Jan
(110) |
Feb
(131) |
Mar
(85) |
Apr
(120) |
May
(82) |
Jun
(101) |
Jul
(54) |
Aug
(65) |
Sep
(94) |
Oct
(51) |
Nov
(56) |
Dec
(168) |
2005 |
Jan
(146) |
Feb
(98) |
Mar
(75) |
Apr
(118) |
May
(85) |
Jun
(75) |
Jul
(44) |
Aug
(94) |
Sep
(70) |
Oct
(84) |
Nov
(115) |
Dec
(52) |
2006 |
Jan
(113) |
Feb
(83) |
Mar
(217) |
Apr
(158) |
May
(219) |
Jun
(218) |
Jul
(189) |
Aug
(39) |
Sep
(3) |
Oct
(7) |
Nov
(4) |
Dec
(2) |
2007 |
Jan
|
Feb
(2) |
Mar
(7) |
Apr
(3) |
May
(3) |
Jun
(8) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(7) |
Dec
|
2008 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2009 |
Jan
(6) |
Feb
|
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(10) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Gavin K. <ga...@ap...> - 2002-11-24 15:38:54
|
This is a tough question to answer.... *yes*, it is supposed to be subclassable; however, I can't make any guarantees that future versions of Hibernate won't break subclasses of EntityPersister. I will try to maintain backward compatibility, but no promises. Sorry.... ----- Original Message ----- From: "Chris Winters" <cwi...@op...> To: "Hibernate Development" <hib...@li...> Sent: Saturday, November 23, 2002 8:23 AM Subject: [Hibernate] EntityPersister subclassable? > I'm finally getting back around to implementing a solution so I can have > a generated field as part of a composite key. (I started back at the end > of September/beginning of October but got pulled away for other tasks.) > > When I first looked at this cirrus.hibernate.persister.EntityPersister > was final so it could not be subclassed and my initial version used > delegation instead of inheritance. I noticed that EntityPersister is no > longer final -- does this mean it's amenable to subclassing? > > I'll probably have some more questions as I go along but it's a start... > > Thanks, > > Chris > > -- > Chris Winters (cwi...@op...) > Java Developer > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Chris W. <cwi...@op...> - 2002-11-22 20:52:08
|
I'm finally getting back around to implementing a solution so I can have a generated field as part of a composite key. (I started back at the end of September/beginning of October but got pulled away for other tasks.) When I first looked at this cirrus.hibernate.persister.EntityPersister was final so it could not be subclassed and my initial version used delegation instead of inheritance. I noticed that EntityPersister is no longer final -- does this mean it's amenable to subclassing? I'll probably have some more questions as I go along but it's a start... Thanks, Chris -- Chris Winters (cwi...@op...) Java Developer |
From: Gavin K. <ga...@ap...> - 2002-11-22 14:33:33
|
I've never seen this problem before, but it looks like Oracle doesn't like the idea of calling Connection.setTransactionIsolation() after callong Connection.setAutocommit(false) This is not a problem for other platforms, but I will swap the order anyway... ----- Original Message ----- From: "Laurent Vanzeune" <lau...@s1...> To: <hib...@li...> Sent: Friday, November 22, 2002 9:14 PM Subject: [Hibernate] HELP: Hibernate and Oracle > > Hi, > > Hibernate: 1.1.8 > Oracle: 9.0.1i > > I first tested my code against SQL Server then I also need tom make it work > under Oracle. When using oracle, and DBCP as connection provider (if set to > C3PO or driver manager it works fine), I received the following exception: > [INFO] Environment - -Hibernate 1.1.6 (?? Release doc says 1.1.8 ??) > [INFO] Environment - -loaded properties from resource hibernate.properties > [INFO] Environment - -using java.io streams to persist binary types > [INFO] Environment - -JVM proxy support: true > [INFO] Dialect - -Using dialect: cirrus.hibernate.sql.OracleDialect > [INFO] ConnectionProviderFactory - -Initializing connection provider: > cirrus.hibernate.connection.DBCPConnectionProvider > [INFO] DBCPConnectionProvider - -DBCP using driver: > oracle.jdbc.driver.OracleDriver at URL: > jdbc:oracle:thin:@localhost:1521:ORACLE > [INFO] DBCPConnectionProvider - -Connection properties: {user=****, > password=****} > [INFO] DBCPConnectionProvider - -JDBC isolation level: READ_COMMITTED > [INFO] SessionFactoryImpl - -JDBC result set fetch size: 25 > [INFO] SessionFactoryImpl - -Use outer join fetching: false > [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 > [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the > first instruction of the transaction > > java.sql.SQLException: ORA-01453: SET TRANSACTION must be the first > instruction of the transaction > > at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) > at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289) > at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573) > at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891) > at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093) > at > oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047 > ) > at > oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940) > at > oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java > :2709) > at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:854) > at > oracle.jdbc.driver.OracleConnection.setTransactionIsolation(OracleConnection > .java:1634) > at > org.apache.commons.dbcp.DelegatingConnection.setTransactionIsolation(Delegat > ingConnection.java:240) > at > org.apache.commons.dbcp.DelegatingConnection.setTransactionIsolation(Delegat > ingConnection.java:240) > at > cirrus.hibernate.connection.DBCPConnectionProvider.getConnection(DBCPConnect > ionProvider.java:41) > at > cirrus.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:149) > at > cirrus.hibernate.impl.DatastoreImpl.buildSessionFactory(DatastoreImpl.java:3 > 23) > at > cirrus.hibernate.impl.DatastoreImpl.buildSessionFactory(DatastoreImpl.java:3 > 14) > at > com.source.frk.dao.persistence.hibernate.HibernateDAO.getSessionFactoryInsta > nce(HibernateDAO.java:44) > at > com.source.frk.dao.persistence.hibernate.HibernateDAO.openSession(HibernateD > AO.java:113) > at > com.source.task.elimination.dao.persistence.hibernate.FinancialInstitutionHi > bernateDAO.insertFinancialInstitutionData(FinancialInstitutionHibernateDAO.j > ava:47) > at > com.source.task.elimination.test.FinancialInstitutionTest.testCrud(Financial > InstitutionTest.java:166) > at java.lang.reflect.Method.invoke(Native Method) > at junit.framework.TestCase.runTest(TestCase.java:166) > at junit.framework.TestCase.runBare(TestCase.java:140) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:131) > at junit.framework.TestSuite.runTest(TestSuite.java:173) > at junit.framework.TestSuite.run(TestSuite.java:168) > at junit.textui.TestRunner.doRun(TestRunner.java:74) > at junit.textui.TestRunner.run(TestRunner.java:200) > at > com.source.task.elimination.test.FinancialInstitutionTest.main(FinancialInst > itutionTest.java:28) > [WARN] SessionFactoryImpl - -Could not obtain connection metadata > <java.sql.SQLException: ORA-01453: SET TRANSACTION must be the first > instruction of the transaction > > > [INFO] SessionFactoryImpl - -Use scrollable result sets: true > [INFO] SessionFactoryImpl - -Transaction strategy: > cirrus.hibernate.transaction.JDBCTransactionFactory > [INFO] SessionFactoryImpl - -echoing all SQL to stdout > [WARN] SessionFactoryObjectFactory - -no JDNI name configured > [INFO] SessionFactoryImpl - -Query language substitutions: {false=0, no='N', > yes='Y', true=1} > [INFO] SessionFactoryImpl - -Query language imports: cirrus.hibernate.test > [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 > [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the > first instruction of the transaction > > [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 > [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the > first instruction of the transaction > > F.[WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 > [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the > first instruction of the transaction > > [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 > [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the > first instruction of the transaction > > Any idea ... thanks in advance! > > L. > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Laurent V. <lau...@s1...> - 2002-11-22 10:14:52
|
Hi, Hibernate: 1.1.8 Oracle: 9.0.1i I first tested my code against SQL Server then I also need tom make it work under Oracle. When using oracle, and DBCP as connection provider (if set to C3PO or driver manager it works fine), I received the following exception: [INFO] Environment - -Hibernate 1.1.6 (?? Release doc says 1.1.8 ??) [INFO] Environment - -loaded properties from resource hibernate.properties [INFO] Environment - -using java.io streams to persist binary types [INFO] Environment - -JVM proxy support: true [INFO] Dialect - -Using dialect: cirrus.hibernate.sql.OracleDialect [INFO] ConnectionProviderFactory - -Initializing connection provider: cirrus.hibernate.connection.DBCPConnectionProvider [INFO] DBCPConnectionProvider - -DBCP using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:ORACLE [INFO] DBCPConnectionProvider - -Connection properties: {user=****, password=****} [INFO] DBCPConnectionProvider - -JDBC isolation level: READ_COMMITTED [INFO] SessionFactoryImpl - -JDBC result set fetch size: 25 [INFO] SessionFactoryImpl - -Use outer join fetching: false [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the first instruction of the transaction java.sql.SQLException: ORA-01453: SET TRANSACTION must be the first instruction of the transaction at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289) at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891) at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093) at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047 ) at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java :2709) at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:854) at oracle.jdbc.driver.OracleConnection.setTransactionIsolation(OracleConnection .java:1634) at org.apache.commons.dbcp.DelegatingConnection.setTransactionIsolation(Delegat ingConnection.java:240) at org.apache.commons.dbcp.DelegatingConnection.setTransactionIsolation(Delegat ingConnection.java:240) at cirrus.hibernate.connection.DBCPConnectionProvider.getConnection(DBCPConnect ionProvider.java:41) at cirrus.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:149) at cirrus.hibernate.impl.DatastoreImpl.buildSessionFactory(DatastoreImpl.java:3 23) at cirrus.hibernate.impl.DatastoreImpl.buildSessionFactory(DatastoreImpl.java:3 14) at com.source.frk.dao.persistence.hibernate.HibernateDAO.getSessionFactoryInsta nce(HibernateDAO.java:44) at com.source.frk.dao.persistence.hibernate.HibernateDAO.openSession(HibernateD AO.java:113) at com.source.task.elimination.dao.persistence.hibernate.FinancialInstitutionHi bernateDAO.insertFinancialInstitutionData(FinancialInstitutionHibernateDAO.j ava:47) at com.source.task.elimination.test.FinancialInstitutionTest.testCrud(Financial InstitutionTest.java:166) at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:166) at junit.framework.TestCase.runBare(TestCase.java:140) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at junit.textui.TestRunner.doRun(TestRunner.java:74) at junit.textui.TestRunner.run(TestRunner.java:200) at com.source.task.elimination.test.FinancialInstitutionTest.main(FinancialInst itutionTest.java:28) [WARN] SessionFactoryImpl - -Could not obtain connection metadata <java.sql.SQLException: ORA-01453: SET TRANSACTION must be the first instruction of the transaction > [INFO] SessionFactoryImpl - -Use scrollable result sets: true [INFO] SessionFactoryImpl - -Transaction strategy: cirrus.hibernate.transaction.JDBCTransactionFactory [INFO] SessionFactoryImpl - -echoing all SQL to stdout [WARN] SessionFactoryObjectFactory - -no JDNI name configured [INFO] SessionFactoryImpl - -Query language substitutions: {false=0, no='N', yes='Y', true=1} [INFO] SessionFactoryImpl - -Query language imports: cirrus.hibernate.test [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the first instruction of the transaction [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the first instruction of the transaction F.[WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the first instruction of the transaction [WARN] JDBCExceptionReporter - -SQL Error: 1453, SQLState: 72000 [ERROR] JDBCExceptionReporter - -ORA-01453: SET TRANSACTION must be the first instruction of the transaction Any idea ... thanks in advance! L. |
From: Christian B. <chr...@bl...> - 2002-11-22 08:15:42
|
On 22 Nov (11:54), Gavin King wrote: > then I will understand your requirements better. As far as I can tell, what > you would really want is either > > select foo from my.Foo > where "baz%" like all foo.bar.elements > > or > > select foo from my.Foo > where "baz%" like some foo.bar.elements Hm, this is equivalent for this purpose. This would be the SQL (simplified): Table FOO { FOO_OID, BAR_OID } Table BARS { BAR_OID, POSN, VALUE } select a.FOO_OID from FOO a, BARS b where a.BAR_OID = b.BAR_OID and b.VALUES like "baz%" -- Christian Bauer tu...@in... |
From: Gavin K. <ga...@ap...> - 2002-11-22 01:03:50
|
Perhaps if you explain the actual SQL you want generated for select foo from my.Foo where foo.bar.values like "baz%" then I will understand your requirements better. As far as I can tell, what you would really want is either select foo from my.Foo where "baz%" like all foo.bar.elements or select foo from my.Foo where "baz%" like some foo.bar.elements ----- Original Message ----- From: "Christian Bauer" <chr...@bl...> To: <hib...@li...> Sent: Friday, November 22, 2002 9:04 AM Subject: [Hibernate] Binary Expressions in Collections > Gavin, the new dereferencing of Collections (my forum post) works great > in CVS. I had to comment out the new Calendar stuff to compile it, though. > > But I found another query structure that is not possible currently: > > I need to compare the values of a collection (a List of Strings) with a > binary operator (= > < like, and so on). > > Foo has a List of Strings named Bar. > > List bars = foo.getBar(); > > The query I need: > > select foo from my.Foo > where foo.bar.values like "baz%" > > The 'values' special property doesn't exist (of course). We have the > 'elements' and 'indices' special properties only (along with 'size' and > other collection related properties). > > I had a look at the generated SQL queries when using 'elments' and > 'indices' and doubt adding 'values' is an easy task. > > 'in', 'some', 'all' and other subselect related expressions only allow > things like > > select foo from my.Foo > where "a_String" in foo.bar.elements > > Of course, no substring searching is possible with this where clause. > The only solution I found is using the existing query facilities and do > substring search in memory/Java. > > -- > Christian Bauer > tu...@in... > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Christian B. <chr...@bl...> - 2002-11-21 22:05:42
|
Gavin, the new dereferencing of Collections (my forum post) works great in CVS. I had to comment out the new Calendar stuff to compile it, though. But I found another query structure that is not possible currently: I need to compare the values of a collection (a List of Strings) with a binary operator (= > < like, and so on). Foo has a List of Strings named Bar. List bars = foo.getBar(); The query I need: select foo from my.Foo where foo.bar.values like "baz%" The 'values' special property doesn't exist (of course). We have the 'elements' and 'indices' special properties only (along with 'size' and other collection related properties). I had a look at the generated SQL queries when using 'elments' and 'indices' and doubt adding 'values' is an easy task. 'in', 'some', 'all' and other subselect related expressions only allow things like select foo from my.Foo where "a_String" in foo.bar.elements Of course, no substring searching is possible with this where clause. The only solution I found is using the existing query facilities and do substring search in memory/Java. -- Christian Bauer tu...@in... |
From: Brad C. <bra...@wo...> - 2002-11-21 21:06:42
|
i think the reason that the default value for lazy is false is that lazy loading imposes some restrictions on the usage of mapped classes, eg. = the session must still be open when u attempt to access the lazily loaded collection. i think your mapping file should stay the same between dev & production, otherwise u might introduce errors that u would probably have caught in development. brad ----- Original Message ----- From: "Donnerstag, Juergen" <jue...@ed...> To: <hib...@li...> Sent: Wednesday, November 20, 2002 8:49 PM Subject: [Hibernate] default for lazy > > The documentation states that the default value for lazy is defined as > false. This is ok, as possible problems are detected more easily = (earlier) > this way. Unfortunately this means you have to manually (or by means = of > XSLT) modify all lazy-attributes in all XML-mappings for production = like > systems. What do you think about a property e.g. hibernate.lazy which > defines the default. If not set or defined, false would be still be = used. > Only relations which are meant to be lazy=3Dfalse during production = would have > to set explicitly. > > regards > Juergen > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > |
From: Brad C. <bra...@wo...> - 2002-11-21 21:05:46
|
The identifier after the "from" does not refer to a table. Perhaps the = fact that your class was named MyTable in your example confused things a = little. As an example: from bar in foo.model.Bar bar is simply an alias for the fully qualified name, much like the "t" = in the following sql statement: select t.* from table t brad ----- Original Message ----- From: "Donnerstag, Juergen" <jue...@ed...> To: <hib...@li...> Sent: Wednesday, November 20, 2002 8:49 PM Subject: [Hibernate] Question about query language > > Would somebody please explain to me why it is necessary to define the table > name as part of the from clause, e.g. "from MYTABLE in class = eg.MyTable". > The relation between table name and java class name is already defined > within the XML mapping. "from MYTABLE" or "from in class eg.MyTable" should > be fine for 90% of all cases. I admit, the latter one looks ugly, = however it > should be sufficient. > > I have one more issue regarding the class name within a literal text. > Automatic refactoring, e.g. renaming the classes name, does not modify = the > class name within the literal text. Any ideas about that? > > regards > Juergen > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > |
From: Boring, J. W, A. <jb...@at...> - 2002-11-21 18:12:13
|
There was talk earlier, like in the 1.1 timeframe of enhancing Hiberate = to allow 1 persistent class to map to more than 1 table. It does not = appear this is included in 1.2 from browsing the new DTD and pdf. Is it? = Are you still planning this enhancement? If the answer is no on all accounts then is there a workaround?=20 Jeff Boring=20 Custom & Web Services Development=20 AT&T Labs=20 jb...@at...=20 |
From: Thomas Q. <tq...@ya...> - 2002-11-21 10:42:13
|
Hi, I have two suggestions: (i) in order to generate the complete API documentation (currently the tools packages are missing) I'd suggest to apply the following diff: Index: build.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/build.xml,v retrieving revision 1.31 diff -r1.31 build.xml 139c139 < packagenames="cirrus.hibernate,cirrus.hibernate.id,cirrus.hibernate.connection,cirrus.hibernate.transaction,cirrus.hibernate.type,cirrus.hibernate.sql,cirrus.hibernate.odmg,cirrus.hibernate.ejb,cirrus.hibernate.cfg,cirrus.hibernate.cache,cirrus.hibernate.jmx,cirrus.hibernate.loader,cirrus.hibernate.persister,cirrus.hibernate.engine,cirrus.hibernate.metadata" --- > packagenames="cirrus.hibernate.*" (ii) I found it somewhat inconvienient that the build file generates the documentation and libs and stuff in a separate directory (../hibernate-<version>). IMHO, this introduces unncessesary hassle with IDE paths as soon as I update my sandbox after a version change; I'd rather see the generated stuff stay in the sandbox. Is there any chance we can change this? I could help out. tom -- thomas quas | "The truth indeed has never been preached by the Buddha, tq...@ya... | seeing that one has to realize it within oneself." | -- Lamkara Sutra -- |
From: Christoph S. <ch...@mc...> - 2002-11-20 11:10:32
|
Hi J=FCrgen! ----- Original Message ----- From: "Donnerstag, Juergen" <jue...@ed...> To: <hib...@li...> Sent: Wednesday, November 20, 2002 11:49 AM Subject: [Hibernate] Question about query language > > Would somebody please explain to me why it is necessary to define the table > name as part of the from clause, e.g. "from MYTABLE in class eg.MyTable= ". > The relation between table name and java class name is already defined > within the XML mapping. "from MYTABLE" or "from in class eg.MyTable" should > be fine for 90% of all cases. I admit, the latter one looks ugly, howev= er it > should be sufficient. if you write from xxx in class yyy, the xxx is used to reference the tabl= e in the where clause (just like sql). you could even write from mytable1 i= n class eg.MyTable, mytable2 in class eg.MyTable..... > > I have one more issue regarding the class name within a literal text. > Automatic refactoring, e.g. renaming the classes name, does not modify = the > class name within the literal text. Any ideas about that? I always write "from xxx in class" + yyy.class.getName() + "...." hth chris > > regards > Juergen > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > |
From: Donnerstag, J. <jue...@ed...> - 2002-11-20 10:50:03
|
Would somebody please explain to me why it is necessary to define the table name as part of the from clause, e.g. "from MYTABLE in class eg.MyTable". The relation between table name and java class name is already defined within the XML mapping. "from MYTABLE" or "from in class eg.MyTable" should be fine for 90% of all cases. I admit, the latter one looks ugly, however it should be sufficient. I have one more issue regarding the class name within a literal text. Automatic refactoring, e.g. renaming the classes name, does not modify the class name within the literal text. Any ideas about that? regards Juergen |
From: Donnerstag, J. <jue...@ed...> - 2002-11-20 10:50:02
|
The documentation states that the default value for lazy is defined as false. This is ok, as possible problems are detected more easily (earlier) this way. Unfortunately this means you have to manually (or by means of XSLT) modify all lazy-attributes in all XML-mappings for production like systems. What do you think about a property e.g. hibernate.lazy which defines the default. If not set or defined, false would be still be used. Only relations which are meant to be lazy=false during production would have to set explicitly. regards Juergen |
From: Mark W. <mor...@SM...> - 2002-11-19 19:56:02
|
Gavin King wrote: >Yes, I *have* thought of that, but it seems so .... model intrusive .... > >Not really in the spirit of the rest of our problem solutions .... > >Part of the reason I'm not really considering this issue a show stopper is >that I really would prefer if people would use generated identifiers ;) > Yeah, but in some cases (eg. mine!) this just isn't possible. I personally would love to see something like what Doug proposed implemented. I already have a couple hacks in my code to do something like this in a couple extreme situations with help from the lifecycle interface... As for it being model intrusive, I don't see a problem with being a little model intrusive to support a use-case that you do not recommend (ie. not using generated identifiers). Just got back from vacation and I can't wait to test out the new normalized table mapping functionality. Thanks, -Mark >----- Original Message ----- >From: "Doug Currie" <e...@fl...> >To: "Gavin King" <ga...@ap...> >Sent: Tuesday, November 19, 2002 9:49 AM >Subject: Re: [hibernate - Open Discussion] RE: cascade save() problem in >one-to-one rel > > > > >>Gavin, >> >>Although I'm still not using Hibernate at my new job, I've been >>lurking on the mailing lists. This question of saveOrUpdate() and >>assigned identifiers seems to come up from time to time. >> >>Wouldn't it be possible to have a property that is not persisted, but >>which flags the instance as persisted or not. It would be initially >>false for transient instances, initially true for instances constructed >>from the database, and set to true when the instance is saved (where >>you'd normally assign the identifier). You'd only need this >>additional property for classes with assigned identifiers that needed >>the saveOrUpdate() capability. >> >>I have no need for this myself, but seeing "theres nothing we can >>really do to improve it..." always gets my attention for a moment! >> >>Regards, >> >>e >> >> >> >>>Read and respond to this message at: >>>https://sourceforge.net/forum/message.php?msg_id=1760812 >>>By: oneovthafew >>> >>> >>>Nah, you just have to accept the fact that saveOrUpdate() can't really >>> >>> >work > > >>>with assigned identifiers. It will always save or always update. The >>> >>> >same comment > > >>>applies to the semantics of cascaded save-update. >>> >>> >>>This is just a limitation of using assigned identifiers and theres >>> >>> >nothing we > > >>>can really do to improve it... >>> >>> > > > >------------------------------------------------------- >This sf.net email is sponsored by: To learn the basics of securing >your web site with SSL, click here to get a FREE TRIAL of a Thawte >Server Certificate: http://www.gothawte.com/rd524.html >_______________________________________________ >hibernate-devel mailing list >hib...@li... >https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > |
From: Stephan A. <Ste...@jc...> - 2002-11-19 19:08:17
|
Hello, we have an application that is developed based on an old version of TopLink. One transaction within the application imports certain files into 5-7 tables accessing another 5-10 tables. We want to get rid of TopLink. Originally, we planned to go EJB, but our tests (even with Local Entities) where not encouraging. Hibernate seems to be a very interesting alternative. Since we currently do not have enough knowledge about Hibernate, we want to contract the job to somebody, 1) who is familiar with Hibernate 2) knows abouts basic performance optimizations and 3) doesn't rip of my jacket to tons of money ;-) 4) could start right now (because I get pressure from the management to make a formal decision for a new mapping tool) We would start with that single transaction (which is fairly complex, so it's an excellent test), see how that works and then go on with more parts of the application. It would be great, if everybody interested to do this, send me a short note. I will get in touch as soon as possible. Also, if anyone has experience in migration from TopLink to Hibernate, I would be glad to hear about that. Thanks, Stephan |
From: Gavin K. <ga...@ap...> - 2002-11-19 13:32:04
|
Yes, I *have* thought of that, but it seems so .... model intrusive .... Not really in the spirit of the rest of our problem solutions .... Part of the reason I'm not really considering this issue a show stopper is that I really would prefer if people would use generated identifiers ;) ----- Original Message ----- From: "Doug Currie" <e...@fl...> To: "Gavin King" <ga...@ap...> Sent: Tuesday, November 19, 2002 9:49 AM Subject: Re: [hibernate - Open Discussion] RE: cascade save() problem in one-to-one rel > Gavin, > > Although I'm still not using Hibernate at my new job, I've been > lurking on the mailing lists. This question of saveOrUpdate() and > assigned identifiers seems to come up from time to time. > > Wouldn't it be possible to have a property that is not persisted, but > which flags the instance as persisted or not. It would be initially > false for transient instances, initially true for instances constructed > from the database, and set to true when the instance is saved (where > you'd normally assign the identifier). You'd only need this > additional property for classes with assigned identifiers that needed > the saveOrUpdate() capability. > > I have no need for this myself, but seeing "theres nothing we can > really do to improve it..." always gets my attention for a moment! > > Regards, > > e > > > Read and respond to this message at: > > https://sourceforge.net/forum/message.php?msg_id=1760812 > > By: oneovthafew > > > Nah, you just have to accept the fact that saveOrUpdate() can't really work > > with assigned identifiers. It will always save or always update. The same comment > > applies to the semantics of cascaded save-update. > > > This is just a limitation of using assigned identifiers and theres nothing we > > can really do to improve it... |
From: Christoph S. <ch...@mc...> - 2002-11-18 15:38:11
|
take a look at nanning, it looks really nice too http://nanning.sf.net I'll make some experiments with it as soon as i find time, and try to ontegrate hibernate into it. peace chris ----- Original Message ----- From: "Gavin King" <ga...@ap...> To: <hib...@li...> Sent: Saturday, November 16, 2002 3:11 PM Subject: Re: [Hibernate] Using hibernate - best practices > Hmmm very cool. > > Hiram are there any ways in which Hibernate could support / integrate better > with this framework? > > ----- Original Message ----- > From: "Hiram Chirino" <hch...@jb...> > To: "Urberg, John" <ju...@ve...>; "'Jozsa Kristof'" > <dy...@on...> > Cc: <hib...@li...> > Sent: Saturday, November 16, 2002 3:49 PM > Subject: RE: [Hibernate] Using hibernate - best practices > > > > First time post... I like hibernate. I want to use it more with the > Aspect > > Framework that I'm build for JBoss. Anyways, here is a way a Jboss aspect > > could help simplify things: > > > > You would use an interceptor that had an invoke method that looked > something > > like: > > > > class HibernateInterceptor { > > ... > > public Object invoke(AspectInvocation invocation) throws Throwable { > > > > HibernateContext oldHC = getHibernateContext(); > > HibernateContext hc = null; > > if( oldHC==null || oldHC.sessionFactory != sessionFactory ) { > > hc = new HibernateContext(); > > hc.sessionFactory = sessionFactory; > > hc.session = sessionFactory.openSession(); > > hc.transaction = hc.session.beginTransaction(); > > setHibernateContext(hc); > > } > > > > try { > > > > Object rc = invocation.invokeNext(); > > > > if( hc != null ) > > hc.transaction.commit(); > > > > return rc; > > > > } catch ( Throwable e ) { > > if( hc != null ) > > hc.transaction.rollback(); > > throw e; > > } finally { > > if( hc != null ) > > hc.session.close(); > > > > setHibernateContext(oldHC); > > } > > } > > .. > > } > > > > class RuleListAction implemetns IRuleListAction { > > .. > > public String doDelete() throws Exception { > > Session session= HibernateInterceptor.getSession(); > > RuleList mo = (RuleList) session.load( RuleList.class, id ); > > session.delete(mo); > > return SUCCESS; > > } > > .. > > } > > > > so that if you have DynamicProxy x with the HibernateInterceptor in the > > invocation chain > > then you could just do a: > > > > IRuleListAction x = (IRuleListAction )AspectFactory(new RuleListAction()); > > x.doDelete() > > > > Regards, > > Hiram > > > > > > > > > -----Original Message----- > > > From: hib...@li... > > > [mailto:hib...@li...]On Behalf Of Urberg, > > > John > > > Sent: Friday, November 15, 2002 8:30 AM > > > To: 'Jozsa Kristof' > > > Cc: hib...@li... > > > Subject: RE: [Hibernate] Using hibernate - best practices > > > > > > > > > >> The InvoiceRepository would be implemented like this: > > > >> [code to load invoices] > > > > > > > And where do you close those opened sessions using this design? Also, > > > where > > > > did you find a place to implement transaction handling, > > > including joining > > > > into existing transactions if possible? > > > > > > That's the responsibility of the database object. Code will usually > look > > > something like this: > > > > > > SomeRepository someRepository = database.getRepository(...); > > > AnotherRepository anotherRepository = database.getRepository(...); > > > database.startTrans(); > > > try { > > > someRepository.update(object); > > > anotherRepository.update(object); > > > database.commit(); > > > } catch (Exception e) { > > > database.rollback(); > > > } > > > > > > All the code for dealing with sessions and transactions is safely tucked > > > away in the database implementation. > > > > > > > These piece of codes are repeating in almost ALL of the Service > classes' > > > > business methods, are just flooding all the logic badly :( > > > > > > I'm not sure how you get around the whole transaction thing > > > unless you're in > > > a J2EE server that does that automatically. If you want to get rid of > the > > > boilerplate code, you could do something like this: > > > > > > public class Database { > > > <...> > > > public void inTransactionDo(Runnable doRun) { > > > Session session = null; > > > Transaction tx = null; > > > try { > > > session = Hibernator.getSession(); > > > tx = session.beginTransaction(); > > > doRun.run(); > > > tx.commit(); > > > } catch (Exception e) { > > > logger.error (<blah/>), e); > > > tx.rollback(); > > > } finally { > > > if (session != null) session.close(); > > > } > > > <...> > > > } > > > > > > Then your business methods would look like this: > > > > > > database.inTransactionDo(new Runnable() { > > > public void run() { > > > <...business logic here...> > > > } > > > } > > > > > > Regards, > > > John Urberg > > > > > > > > > ------------------------------------------------------- > > > This sf.net email is sponsored by: To learn the basics of securing > > > your web site with SSL, click here to get a FREE TRIAL of a Thawte > > > Server Certificate: http://www.gothawte.com/rd524.html > > > _______________________________________________ > > > hibernate-devel mailing list > > > hib...@li... > > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by: To learn the basics of securing > > your web site with SSL, click here to get a FREE TRIAL of a Thawte > > Server Certificate: http://www.gothawte.com/rd524.html > > _______________________________________________ > > hibernate-devel mailing list > > hib...@li... > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > |
From: Donnie H. <do...@ha...> - 2002-11-16 19:28:42
|
Here's what I like: Define a service interface which specifies the high-level business operations. The implementation of that interface would be in terms of the business/domain model objects. I'd keep hibernate code out of those objects to the degree that's possible. The trick, then, is to use a dynamic proxy in front of the object implementing the service interface. The "client" of the service interface thinks it's dealing directly w/ some object that implements that interface, when in fact it's got an instance of a proxy. In the "invoke" method of the proxy class (i.e. the one which implements InvocationHandler), put the code to initiate and commit/abort transactions, log method entry & exit, handle exceptions, etc. So now that's done for all business operations in a single place, and every time you tweak the service implementation or add a new method, you don't have to have all this boilerplate code. Put connection/session info which is established in the proxy's invoke method in a ThreadLocal which can be used by the layer which deals w/ hibernate. I've done this both with in-process services and service interfaces implemented as stateless session beans. FWIW... Donnie -----Original Message----- From: hib...@li... [mailto:hib...@li...]On Behalf Of Ampie Barnard Sent: Friday, November 15, 2002 2:22 AM To: hib...@li... Subject: RE: [Hibernate] Using hibernate - best practices I like the services-layer idea, but also have to agree that it leads to repetitive code. In our system, we have implemented the service layer as session beans. The transaction management is taken care of by the container. But we still have the repititive try{ opensession(); }catch(Exception e){ rolbackSession();throw e; }finally{ closession(); } I have also simply sacrificed session propagation from one session bean to another. If someone were to implement the sessionFactory as a JCA connector, all of this code would become the responsibility of the container. It would also do the propagation of transaction contexts. As an interim solution, someone could perhaps implement a "stateless" version of the session factory that automatically flushes and closes itself when a transaction commits, and closes when the transaction rolls back. Am I on the right track here? -----Original Message----- From: hib...@li... [mailto:hib...@li...]On Behalf Of Jozsa Kristof Sent: 15 November 2002 01:02 To: Urberg, John Cc: hib...@li... Subject: Re: [Hibernate] Using hibernate - best practices On Thu, Nov 14, 2002 at 01:36:13PM -0600, Urberg, John wrote: .. > The InvoiceRepository would be implemented like this: > > public class HibernateInvoiceRepository { > public void setDatabase(Database database) { _database = > (HibernateDatabase) database; } > public List getOverdueInvoices() { > return database.getSession().find("<hibernate query>"); > } > public void update(Object object) { > database.getSession().saveOrUpdate(object); > } > } > And where do you close those opened sessions using this design? Also, where did you find a place to implement transaction handling, including joining into existing transactions if possible? I have my own pieces of ideas how to implement a design for Hibernate, but I'm fighting with the questions listed above too. Got some workaround, but kinda far from being perfect.. Mainly I used Ralf's third possible solution from these: > > * Put everything into the domain classes. > > * Implement something like a "Home" interface > > * Implement some sort of component-like / "Service" interface ..having a layer of 'service-like' components in charge of database-related operations, which either use Hibernate (98%) or plain JDBC pulling the connection from a Hibernate session. These components are always pulled by the upper layer from a plain component pool, which I implemented myself. But mentioning one returning problem, I have *LOTS* of repeated code parts like these: Session session = null; Transaction tx = null; try { session = Hibernator.getSession(); // my custom class which keeps the sessions and initializes Hibernate tx = session.beginTransaction(); .. .. tx.commit(); } catch (Exception e) { logger.error (<blah/>), e); tx.rollback(); // rethrow business-exception if suitable } finally { if (session != null) session.close(); } These piece of codes are repeating in almost ALL of the Service classes' business methods, are just flooding all the logic badly :( (ok, tx handling is missing from this where i'm doing read-only operations, but still..) I also have some part-solution related to joining to existing transactions, but I find it snappy too. So, as I said, I don't feel my design good at all.. just couldn't find out any better for the moment. Therefore, I'd be very happy and thankful to read about others experiences and concrete architecture/design plans. Regards, dyn -- .Digital.Yearning.for.Networked.Assassination.and.Xenocide ------------------------------------------------------- This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html _______________________________________________ hibernate-devel mailing list hib...@li... https://lists.sourceforge.net/lists/listinfo/hibernate-devel ------------------------------------------------------- This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html _______________________________________________ hibernate-devel mailing list hib...@li... https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Gavin K. <ga...@ap...> - 2002-11-16 14:21:27
|
>If someone were to implement the sessionFactory as a JCA connector, all of >this code would become the responsibility of the container. It would also do >the propagation of transaction contexts. I am looking into implementing a JCA connector, by the way.... |
From: Gavin K. <ga...@ap...> - 2002-11-16 14:18:08
|
The way I handle this is to use a command framework, where there is a session bean that acts as a command execution context. exception handling like this can then be built (once) into either the command bean or session bean. I don't find it necessary to have a different session bean remote method for each application task. ----- Original Message ----- From: "Ampie Barnard" <amp...@mw...> To: <hib...@li...> Sent: Friday, November 15, 2002 6:21 PM Subject: RE: [Hibernate] Using hibernate - best practices > I like the services-layer idea, but also have to agree that it leads to > repetitive code. > > In our system, we have implemented the service layer as session beans. The > transaction management is taken care of by the container. But we still have > the repititive > try{ > opensession(); > }catch(Exception e){ > rolbackSession();throw e; > }finally{ > closession(); > } > I have also simply sacrificed session propagation from one session bean to > another. > > If someone were to implement the sessionFactory as a JCA connector, all of > this code would become the responsibility of the container. It would also do > the propagation of transaction contexts. > > As an interim solution, someone could perhaps implement a "stateless" > version of the session factory that automatically flushes and closes itself > when a transaction commits, and closes when the transaction rolls back. > > Am I on the right track here? > > > -----Original Message----- > From: hib...@li... > [mailto:hib...@li...]On Behalf Of Jozsa > Kristof > Sent: 15 November 2002 01:02 > To: Urberg, John > Cc: hib...@li... > Subject: Re: [Hibernate] Using hibernate - best practices > > > On Thu, Nov 14, 2002 at 01:36:13PM -0600, Urberg, John wrote: > .. > > The InvoiceRepository would be implemented like this: > > > > public class HibernateInvoiceRepository { > > public void setDatabase(Database database) { _database = > > (HibernateDatabase) database; } > > public List getOverdueInvoices() { > > return database.getSession().find("<hibernate query>"); > > } > > public void update(Object object) { > > database.getSession().saveOrUpdate(object); > > } > > } > > > > And where do you close those opened sessions using this design? Also, where > did you find a place to implement transaction handling, including joining > into existing transactions if possible? > > I have my own pieces of ideas how to implement a design for Hibernate, but > I'm fighting with the questions listed above too. Got some workaround, but > kinda far from being perfect.. Mainly I used Ralf's third possible solution > from these: > > > > * Put everything into the domain classes. > > > * Implement something like a "Home" interface > > > * Implement some sort of component-like / "Service" interface > > ..having a layer of 'service-like' components in charge of database-related > operations, which either use Hibernate (98%) or plain JDBC pulling the > connection from a Hibernate session. These components are always pulled by > the upper layer from a plain component pool, which I implemented myself. But > mentioning one returning problem, I have *LOTS* of repeated code parts like > these: > > Session session = null; > Transaction tx = null; > try { > session = Hibernator.getSession(); // my custom class which keeps > the sessions and initializes Hibernate > tx = session.beginTransaction(); > .. > .. > tx.commit(); > } catch (Exception e) { > logger.error (<blah/>), e); > tx.rollback(); > // rethrow business-exception if suitable > } finally { > if (session != null) session.close(); > } > > These piece of codes are repeating in almost ALL of the Service classes' > business methods, are just flooding all the logic badly :( (ok, tx handling > is missing from this where i'm doing read-only operations, but still..) I > also have some part-solution related to joining to existing transactions, > but I find it snappy too. > > So, as I said, I don't feel my design good at all.. just couldn't find out > any better for the moment. Therefore, I'd be very happy and thankful to read > about others experiences and concrete architecture/design plans. > > Regards, > dyn > -- > .Digital.Yearning.for.Networked.Assassination.and.Xenocide > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Gavin K. <ga...@ap...> - 2002-11-16 14:15:02
|
I can see how this would be nice, but hibernate.query.imports already makes me feel a bit quesy (and can be a source of bugs). I don't really wish to compound this by introducing a similar thing into the mapping files. ----- Original Message ----- From: "Donnerstag, Juergen" <jue...@ed...> To: <hib...@li...> Sent: Friday, November 15, 2002 10:48 PM Subject: [Hibernate] XML Mapping Option: class prefix > > I'm fairly new to hibernate. Please apologize if this is silly question. > > I have several XML mapping files, one for each table. Each mapping file > contains several locations where fully qualified class names are required. > > Like hibernate.query.imports is there a way to define the package, or at > least some common root package which is used as a common prefix. I wouldn't > have to type in the fully qualified class name over and over again. Besides > it makes it easier to modify and more flexible. I could imagine a hibernate > property as default location and <hibernate-mapping> and <class> as > redefinition in case it is needed. > > regards > Jürgen > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Gavin K. <ga...@ap...> - 2002-11-16 14:12:41
|
Hmmm very cool. Hiram are there any ways in which Hibernate could support / integrate better with this framework? ----- Original Message ----- From: "Hiram Chirino" <hch...@jb...> To: "Urberg, John" <ju...@ve...>; "'Jozsa Kristof'" <dy...@on...> Cc: <hib...@li...> Sent: Saturday, November 16, 2002 3:49 PM Subject: RE: [Hibernate] Using hibernate - best practices > First time post... I like hibernate. I want to use it more with the Aspect > Framework that I'm build for JBoss. Anyways, here is a way a Jboss aspect > could help simplify things: > > You would use an interceptor that had an invoke method that looked something > like: > > class HibernateInterceptor { > ... > public Object invoke(AspectInvocation invocation) throws Throwable { > > HibernateContext oldHC = getHibernateContext(); > HibernateContext hc = null; > if( oldHC==null || oldHC.sessionFactory != sessionFactory ) { > hc = new HibernateContext(); > hc.sessionFactory = sessionFactory; > hc.session = sessionFactory.openSession(); > hc.transaction = hc.session.beginTransaction(); > setHibernateContext(hc); > } > > try { > > Object rc = invocation.invokeNext(); > > if( hc != null ) > hc.transaction.commit(); > > return rc; > > } catch ( Throwable e ) { > if( hc != null ) > hc.transaction.rollback(); > throw e; > } finally { > if( hc != null ) > hc.session.close(); > > setHibernateContext(oldHC); > } > } > .. > } > > class RuleListAction implemetns IRuleListAction { > .. > public String doDelete() throws Exception { > Session session= HibernateInterceptor.getSession(); > RuleList mo = (RuleList) session.load( RuleList.class, id ); > session.delete(mo); > return SUCCESS; > } > .. > } > > so that if you have DynamicProxy x with the HibernateInterceptor in the > invocation chain > then you could just do a: > > IRuleListAction x = (IRuleListAction )AspectFactory(new RuleListAction()); > x.doDelete() > > Regards, > Hiram > > > > > -----Original Message----- > > From: hib...@li... > > [mailto:hib...@li...]On Behalf Of Urberg, > > John > > Sent: Friday, November 15, 2002 8:30 AM > > To: 'Jozsa Kristof' > > Cc: hib...@li... > > Subject: RE: [Hibernate] Using hibernate - best practices > > > > > > >> The InvoiceRepository would be implemented like this: > > >> [code to load invoices] > > > > > And where do you close those opened sessions using this design? Also, > > where > > > did you find a place to implement transaction handling, > > including joining > > > into existing transactions if possible? > > > > That's the responsibility of the database object. Code will usually look > > something like this: > > > > SomeRepository someRepository = database.getRepository(...); > > AnotherRepository anotherRepository = database.getRepository(...); > > database.startTrans(); > > try { > > someRepository.update(object); > > anotherRepository.update(object); > > database.commit(); > > } catch (Exception e) { > > database.rollback(); > > } > > > > All the code for dealing with sessions and transactions is safely tucked > > away in the database implementation. > > > > > These piece of codes are repeating in almost ALL of the Service classes' > > > business methods, are just flooding all the logic badly :( > > > > I'm not sure how you get around the whole transaction thing > > unless you're in > > a J2EE server that does that automatically. If you want to get rid of the > > boilerplate code, you could do something like this: > > > > public class Database { > > <...> > > public void inTransactionDo(Runnable doRun) { > > Session session = null; > > Transaction tx = null; > > try { > > session = Hibernator.getSession(); > > tx = session.beginTransaction(); > > doRun.run(); > > tx.commit(); > > } catch (Exception e) { > > logger.error (<blah/>), e); > > tx.rollback(); > > } finally { > > if (session != null) session.close(); > > } > > <...> > > } > > > > Then your business methods would look like this: > > > > database.inTransactionDo(new Runnable() { > > public void run() { > > <...business logic here...> > > } > > } > > > > Regards, > > John Urberg > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by: To learn the basics of securing > > your web site with SSL, click here to get a FREE TRIAL of a Thawte > > Server Certificate: http://www.gothawte.com/rd524.html > > _______________________________________________ > > hibernate-devel mailing list > > hib...@li... > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Hiram C. <hch...@jb...> - 2002-11-16 04:50:57
|
First time post... I like hibernate. I want to use it more with the Aspect Framework that I'm build for JBoss. Anyways, here is a way a Jboss aspect could help simplify things: You would use an interceptor that had an invoke method that looked something like: class HibernateInterceptor { ... public Object invoke(AspectInvocation invocation) throws Throwable { HibernateContext oldHC = getHibernateContext(); HibernateContext hc = null; if( oldHC==null || oldHC.sessionFactory != sessionFactory ) { hc = new HibernateContext(); hc.sessionFactory = sessionFactory; hc.session = sessionFactory.openSession(); hc.transaction = hc.session.beginTransaction(); setHibernateContext(hc); } try { Object rc = invocation.invokeNext(); if( hc != null ) hc.transaction.commit(); return rc; } catch ( Throwable e ) { if( hc != null ) hc.transaction.rollback(); throw e; } finally { if( hc != null ) hc.session.close(); setHibernateContext(oldHC); } } .. } class RuleListAction implemetns IRuleListAction { .. public String doDelete() throws Exception { Session session= HibernateInterceptor.getSession(); RuleList mo = (RuleList) session.load( RuleList.class, id ); session.delete(mo); return SUCCESS; } .. } so that if you have DynamicProxy x with the HibernateInterceptor in the invocation chain then you could just do a: IRuleListAction x = (IRuleListAction )AspectFactory(new RuleListAction()); x.doDelete() Regards, Hiram > -----Original Message----- > From: hib...@li... > [mailto:hib...@li...]On Behalf Of Urberg, > John > Sent: Friday, November 15, 2002 8:30 AM > To: 'Jozsa Kristof' > Cc: hib...@li... > Subject: RE: [Hibernate] Using hibernate - best practices > > > >> The InvoiceRepository would be implemented like this: > >> [code to load invoices] > > > And where do you close those opened sessions using this design? Also, > where > > did you find a place to implement transaction handling, > including joining > > into existing transactions if possible? > > That's the responsibility of the database object. Code will usually look > something like this: > > SomeRepository someRepository = database.getRepository(...); > AnotherRepository anotherRepository = database.getRepository(...); > database.startTrans(); > try { > someRepository.update(object); > anotherRepository.update(object); > database.commit(); > } catch (Exception e) { > database.rollback(); > } > > All the code for dealing with sessions and transactions is safely tucked > away in the database implementation. > > > These piece of codes are repeating in almost ALL of the Service classes' > > business methods, are just flooding all the logic badly :( > > I'm not sure how you get around the whole transaction thing > unless you're in > a J2EE server that does that automatically. If you want to get rid of the > boilerplate code, you could do something like this: > > public class Database { > <...> > public void inTransactionDo(Runnable doRun) { > Session session = null; > Transaction tx = null; > try { > session = Hibernator.getSession(); > tx = session.beginTransaction(); > doRun.run(); > tx.commit(); > } catch (Exception e) { > logger.error (<blah/>), e); > tx.rollback(); > } finally { > if (session != null) session.close(); > } > <...> > } > > Then your business methods would look like this: > > database.inTransactionDo(new Runnable() { > public void run() { > <...business logic here...> > } > } > > Regards, > John Urberg > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Urberg, J. <ju...@ve...> - 2002-11-15 13:32:01
|
>> The InvoiceRepository would be implemented like this: >> [code to load invoices] > And where do you close those opened sessions using this design? Also, where > did you find a place to implement transaction handling, including joining > into existing transactions if possible? That's the responsibility of the database object. Code will usually look something like this: SomeRepository someRepository = database.getRepository(...); AnotherRepository anotherRepository = database.getRepository(...); database.startTrans(); try { someRepository.update(object); anotherRepository.update(object); database.commit(); } catch (Exception e) { database.rollback(); } All the code for dealing with sessions and transactions is safely tucked away in the database implementation. > These piece of codes are repeating in almost ALL of the Service classes' > business methods, are just flooding all the logic badly :( I'm not sure how you get around the whole transaction thing unless you're in a J2EE server that does that automatically. If you want to get rid of the boilerplate code, you could do something like this: public class Database { <...> public void inTransactionDo(Runnable doRun) { Session session = null; Transaction tx = null; try { session = Hibernator.getSession(); tx = session.beginTransaction(); doRun.run(); tx.commit(); } catch (Exception e) { logger.error (<blah/>), e); tx.rollback(); } finally { if (session != null) session.close(); } <...> } Then your business methods would look like this: database.inTransactionDo(new Runnable() { public void run() { <...business logic here...> } } Regards, John Urberg |