Re: T5: Hibernate
How about this? http://tapestry.1045711.n5.nabble.com/T5-Working-Tapestry-Hibernate-with-DAO-td3229905.html http://tapestry.1045711.n5.nabble.com/T5-Working-Tapestry-Hibernate-with-DAO-td3229905.html -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Hibernate-tp2409789p3290129.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: T5: Hibernate
I remember that I got errors with hibernate, when I had different versions of hibernate core and hibernate annotations combined ( in my case 3.6 with 3.5.6). Downgrading both to 3.5.6 solved it. No idea, what's behind it, I'm not very familiar with hibernate, but I saw you have hibernate with 3.2.2.ga and hibernate annotations with 3.2.1.ga Jens Reufsteck -Original Message- From: robnangle [mailto:robnan...@gmail.com] Sent: Tuesday, November 30, 2010 11:25 AM To: users@tapestry.apache.org Subject: Re: T5: Hibernate Hi, Im trying to get this example but keep getting the same two errors. Any help would be greatly appreciated. org.apache.tapestry5.internal.services.TransformationException: java.lang.ClassNotFoundException: org.apache.tapestry5.hibernate.annotations.CommitAfter org.apache.tapestry5.internal.services.TransformationException: javassist.NotFoundException: org.hibernate.Session (when I take out the commitAfter) -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Hibernate- tp2409789p3285852.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate
Hi, Im trying to get this example but keep getting the same two errors. Any help would be greatly appreciated. org.apache.tapestry5.internal.services.TransformationException: java.lang.ClassNotFoundException: org.apache.tapestry5.hibernate.annotations.CommitAfter org.apache.tapestry5.internal.services.TransformationException: javassist.NotFoundException: org.hibernate.Session (when I take out the commitAfter) -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Hibernate-tp2409789p3285852.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate
Hard to say without further details. E.g. are you running in an IDE, with Ant, Maven or something similar?
Re: T5: Hibernate
Hi, Yes im running it in eclipse as my ide tomcat as my server mysql as my database -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Hibernate-tp2409789p3286828.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate
Are you using maven and m2eclipse plugin? I don't know if it could help but... Well, right click on the project on eclipse and choose Run as Maven Install . Check if there is any build problem. You could run a Run Maven Clean or Maven Update Dependencies also. Keep an eye on the Maven's Console for any problem. Well, since there's not much info, maybe it could help someway. ___ Everton Agner Ramos 2010/11/30 robnangle robnan...@gmail.com Hi, Yes im running it in eclipse as my ide tomcat as my server mysql as my database -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Hibernate-tp2409789p3286828.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5+hibernate - multiple session factories
Hi, I have done this successfully but i had to create my own implementations of HibernateConfigurer, HibernateSessionManager and HibernateSessionSource. There is also an open issue about this: https://issues.apache.org/jira/browse/TAP5-48 https://issues.apache.org/jira/browse/TAP5-48 -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-hibernate-multiple-session-factories-tp2838477p2838865.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5+hibernate - multiple session factories
oh,I found hibernate shards? It handle multiple database naturally. anyone used it with T5? hibernate shards:http://www.hibernate.org/subprojects/shards.html On Tue, Sep 14, 2010 at 5:17 PM, antalk ant...@intercommit.nl wrote: Hi, I have done this successfully but i had to create my own implementations of HibernateConfigurer, HibernateSessionManager and HibernateSessionSource. There is also an open issue about this: https://issues.apache.org/jira/browse/TAP5-48 https://issues.apache.org/jira/browse/TAP5-48 -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-hibernate-multiple-session-factories-tp2838477p2838865.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: cleverpig.name/dan/ Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5+hibernate - multiple session factories
I have an tapestry app that needs to connect to 2 different databases. Has anyone done this with tapestry-hibernate? thanks, p. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5+hibernate - multiple session factories
well I am using spring + hibernate(JPA features) ,you can set up two more persist unit. On 2010-9-14 8:31, Paul Stanton wrote: I have an tapestry app that needs to connect to 2 different databases. Has anyone done this with tapestry-hibernate? thanks, p. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5+hibernate - multiple session factories
you guy,maybe you should hack hibernate module to support multiple datasource. On Tue, Sep 14, 2010 at 9:35 AM, Fanzhen fanzhen.m...@hotmail.com wrote: well I am using spring + hibernate(JPA features) ,you can set up two more persist unit. On 2010-9-14 8:31, Paul Stanton wrote: I have an tapestry app that needs to connect to 2 different databases. Has anyone done this with tapestry-hibernate? thanks, p. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: cleverpig.name/dan/ Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5:hibernate @Length validator doesn't work
thanks! On Sat, Oct 3, 2009 at 2:38 AM, Valentin Yerastov xib...@gmail.com wrote: Try this project http://code.google.com/p/tapestry-validator/ cleverpig-2 wrote: hi,all! i got a trouble in hibernate @Length validator with Tapestry 5.1. i think it's a easy-meet problem for newbie(it's me). @Entity @Table(name=hello) public class Hello implements Serializable{ ... @NotNull(message={hello.message.notnull}) @Length(min=10,max=20) @Column(name=message,length=20) private String message; ... } but i can update or create 'hello' record to database with beanEditForm. somebody got this?who can give me suggestiong? thanks! -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- View this message in context: http://www.nabble.com/T5%3Ahibernate-%40Length-validator-doesn%27t-work-tp25468952p25720525.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5:hibernate @Length validator doesn't work
Try this project http://code.google.com/p/tapestry-validator/ cleverpig-2 wrote: hi,all! i got a trouble in hibernate @Length validator with Tapestry 5.1. i think it's a easy-meet problem for newbie(it's me). @Entity @Table(name=hello) public class Hello implements Serializable{ ... @NotNull(message={hello.message.notnull}) @Length(min=10,max=20) @Column(name=message,length=20) private String message; ... } but i can update or create 'hello' record to database with beanEditForm. somebody got this?who can give me suggestiong? thanks! -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- View this message in context: http://www.nabble.com/T5%3Ahibernate-%40Length-validator-doesn%27t-work-tp25468952p25720525.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5 Hibernate
Hello, Can someone point me to the most up-to-date and detailed documentation on using Hibernate with T5 (but not Spring)? Thank you, Benny
Re: T5 Hibernate
Hi Thiago, Thanks for responding, but I was hoping for something a little more detailed. I had visited this link before, but needed more details on things such as configuration and code examples. I have an existing database, and would like to map my models to the existing tables using annotations. I would like to know what I need in terms of configuration and what to inject into my DAO's to get a Hibernate session. If you could give me a few more pointers, I would really appreciate it. Benny On Tue, Sep 29, 2009 at 3:32 PM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: Em Tue, 29 Sep 2009 16:23:02 -0300, Benny Law benny.mk@gmail.com escreveu: Hello, Hi! Can someone point me to the most up-to-date and detailed documentation on using Hibernate with T5 (but not Spring)? http://tapestry.apache.org/tapestry5.1/tapestry-hibernate/ -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 Hibernate
Em Tue, 29 Sep 2009 16:23:02 -0300, Benny Law benny.mk@gmail.com escreveu: Hello, Hi! Can someone point me to the most up-to-date and detailed documentation on using Hibernate with T5 (but not Spring)? http://tapestry.apache.org/tapestry5.1/tapestry-hibernate/ -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 Hibernate
Em Tue, 29 Sep 2009 17:00:34 -0300, Benny Law benny.mk@gmail.com escreveu: Hi Thiago, Hi! Thanks for responding, but I was hoping for something a little more detailed. I had visited this link before, but needed more details on things such as configuration and code examples. Configuration: http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html I have an existing database, and would like to map my models to the existing tables using annotations. Use Hibernate Tools (Eclipse plugin) to generate the entity classes through database reverse engineering. I would like to know what I need in terms of configuration and what to inject into my DAO's to get a Hibernate session. Declare your DAOs as Tapestry-IoC services and have the Session injected in them. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 Hibernate
Thanks Thiago. Somehow, I missed those additional links in the left nav. Now I have a bit more info to go on. Benny On Tue, Sep 29, 2009 at 4:52 PM, Thiago H. de Paula Figueiredo thiag...@gmail.com wrote: Em Tue, 29 Sep 2009 17:00:34 -0300, Benny Law benny.mk@gmail.com escreveu: Hi Thiago, Hi! Thanks for responding, but I was hoping for something a little more detailed. I had visited this link before, but needed more details on things such as configuration and code examples. Configuration: http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html I have an existing database, and would like to map my models to the existing tables using annotations. Use Hibernate Tools (Eclipse plugin) to generate the entity classes through database reverse engineering. I would like to know what I need in terms of configuration and what to inject into my DAO's to get a Hibernate session. Declare your DAOs as Tapestry-IoC services and have the Session injected in them. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 Hibernate
amazing, i did not know that we can configure manually until reading that link: apestry.hibernate.default-configuration is there a short sample that how this can be be used? Thanks, angelo Thiago H. de Paula Figueiredo wrote: Em Tue, 29 Sep 2009 17:00:34 -0300, Benny Law benny.mk@gmail.com escreveu: Hi Thiago, Hi! Thanks for responding, but I was hoping for something a little more detailed. I had visited this link before, but needed more details on things such as configuration and code examples. Configuration: http://tapestry.apache.org/tapestry5.1/tapestry-hibernate-core/conf.html I have an existing database, and would like to map my models to the existing tables using annotations. Use Hibernate Tools (Eclipse plugin) to generate the entity classes through database reverse engineering. I would like to know what I need in terms of configuration and what to inject into my DAO's to get a Hibernate session. Declare your DAOs as Tapestry-IoC services and have the Session injected in them. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- View this message in context: http://www.nabble.com/T5---Hibernate-tp25669279p25672391.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5:hibernate @Length validator doesn't work
hi,all! i got a trouble in hibernate @Length validator with Tapestry 5.1. i think it's a easy-meet problem for newbie(it's me). @Entity @Table(name=hello) public class Hello implements Serializable{ ... @NotNull(message={hello.message.notnull}) @Length(min=10,max=20) @Column(name=message,length=20) private String message; ... } but i can update or create 'hello' record to database with beanEditForm. somebody got this?who can give me suggestiong? thanks! -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5:hibernate @Length validator doesn't work
hi, the beandeditor cannot handle Hibernate annotations. you have to use the tapestry specific validators. g, kris cleverpig greatclever...@gmail.com 16.09.2009 11:28 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema T5:hibernate @Length validator doesn't work hi,all! i got a trouble in hibernate @Length validator with Tapestry 5.1. i think it's a easy-meet problem for newbie(it's me). @Entity @Table(name=hello) public class Hello implements Serializable{ ... @NotNull(message={hello.message.notnull}) @Length(min=10,max=20) @Column(name=message,length=20) private String message; ... } but i can update or create 'hello' record to database with beanEditForm. somebody got this?who can give me suggestiong? thanks! -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5:hibernate @Length validator doesn't work
Thiago has a project in Ars Machina that allows to use the hibernate validators with Tapestry. U may find it useful http://www.arsmachina.com.br/project/tapestrycrudhibernatevalidator 2009/9/16 Kristian Marinkovic kristian.marinko...@porsche.co.at: hi, the beandeditor cannot handle Hibernate annotations. you have to use the tapestry specific validators. g, kris cleverpig greatclever...@gmail.com 16.09.2009 11:28 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema T5:hibernate @Length validator doesn't work hi,all! i got a trouble in hibernate @Length validator with Tapestry 5.1. i think it's a easy-meet problem for newbie(it's me). @Entity @Table(name=hello) public class Hello implements Serializable{ ... @NotNull(message={hello.message.notnull}) @Length(min=10,max=20) @Column(name=message,length=20) private String message; ... } but i can update or create 'hello' record to database with beanEditForm. somebody got this?who can give me suggestiong? thanks! -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5:hibernate @Length validator doesn't work
thanks you all! i found @NotNull annotation always work on tapestry! but @Length...so how to backend data validator in tapestry? will make a custom function on serverside's event handler? On Wed, Sep 16, 2009 at 7:44 PM, Juan E. Maya maya.j...@gmail.com wrote: Thiago has a project in Ars Machina that allows to use the hibernate validators with Tapestry. U may find it useful http://www.arsmachina.com.br/project/tapestrycrudhibernatevalidator 2009/9/16 Kristian Marinkovic kristian.marinko...@porsche.co.at: hi, the beandeditor cannot handle Hibernate annotations. you have to use the tapestry specific validators. g, kris cleverpig greatclever...@gmail.com 16.09.2009 11:28 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema T5:hibernate @Length validator doesn't work hi,all! i got a trouble in hibernate @Length validator with Tapestry 5.1. i think it's a easy-meet problem for newbie(it's me). @Entity @Table(name=hello) public class Hello implements Serializable{ ... @NotNull(message={hello.message.notnull}) @Length(min=10,max=20) @Column(name=message,length=20) private String message; ... } but i can update or create 'hello' record to database with beanEditForm. somebody got this?who can give me suggestiong? thanks! -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
t5: hibernate connection string
Hi, I use following in hibernate.cfg.xml to connect to database: property name=hibernate.connection.urljdbc:mysql://localhost/stock?autoReconnect=true/property This works very well, but it is hard coded, is there a way to put the particular info in a property file, then pick it up when the t5 program is loaded? Thanks, Angelo -- View this message in context: http://www.nabble.com/t5%3A-hibernate-connection-string-tp2500p2500.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: t5: hibernate connection string
contribute a HibernateConfigurer to the HibernateSessionSource service. Although I don't quite get why putting the connection string into a properties file is any different than putting it in the xml file... Uli On 17.08.2009 15:21 schrieb Angelo Chen: Hi, I use following in hibernate.cfg.xml to connect to database: property name=hibernate.connection.urljdbc:mysql://localhost/stock?autoReconnect=true/property This works very well, but it is hard coded, is there a way to put the particular info in a property file, then pick it up when the t5 program is loaded? Thanks, Angelo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: t5: hibernate connection string
Hi Uli, Thanks for the quick response, leaving it in XML is fine, problem is, the xml file is packaged into a jar, can not find it under the 'ROOT' directory for me to update, any idea putting that hibernate.cfg.xml somewhere else, say WEB-INF? Ulrich Stärk wrote: contribute a HibernateConfigurer to the HibernateSessionSource service. Although I don't quite get why putting the connection string into a properties file is any different than putting it in the xml file... Uli On 17.08.2009 15:21 schrieb Angelo Chen: Hi, I use following in hibernate.cfg.xml to connect to database: property name=hibernate.connection.urljdbc:mysql://localhost/stock?autoReconnect=true/property This works very well, but it is hard coded, is there a way to put the particular info in a property file, then pick it up when the t5 program is loaded? Thanks, Angelo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- View this message in context: http://www.nabble.com/t5%3A-hibernate-connection-string-tp2500p25007693.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5 Hibernate listener crash problem - problem with classloader?
If I configuer my AuditListener in the hibernate.cfg.xml file like this listener type=pre-insert class=net.weissboeck.gimmo.entities.AuditListener/ im getting the following error after first acces to database: [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: Exception constructing service 'ValueEncoderSource': Error invoking service builder method org .apache.tapestry5.services.TapestryModule.buildValueEncoderSource(Map, InvalidationEventHub) (at TapestryModule.java:1910) (for service 'ValueEncoderSource'): Error invoking service contribution method org .apache .tapestry5 .hibernate .HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource): Exception constructing service 'HibernateSessionSource': Error invoking service builder method org .apache .tapestry5 .hibernate.HibernateCoreModule.buildHibernateSessionSource(Logger, List, RegistryShutdownHub) (at HibernateCoreModule.java:123) (for service 'HibernateSessionSource'): Unable to instantiate specified event (pre-insert) listener class: net.weissboeck.gimmo.entities.AuditListener Debugging seems to indicate a problem with the classloader. Has anyone got hibernate listeners working with T5 hibernate module? This is my AuditListener class (I use a common abstract base entity with alle the technical and audit data for all my entities) package net.weissboeck.gimmo.entities; import java.util.Date; import org.hibernate.event.PreUpdateEvent; import org.hibernate.event.PreUpdateEventListener; public class AuditListener implements PreUpdateEventListener { private static final long serialVersionUID = 1L; @Override public boolean onPreUpdate(PreUpdateEvent pEvent) { AbstractBaseEntity entity = (AbstractBaseEntity) pEvent.getEntity(); entity.setLastUpdated(new Date()); return false; } } - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 Hibernate listener crash problem - problem with classloader?
On Tue, Jun 23, 2009 at 9:17 AM, Max Weißböck (info) m...@weissboeck.info wrote: service 'HibernateSessionSource'): Unable to instantiate specified event (pre-insert) listener class: net.weissboeck.gimmo.entities.AuditListener Couldn't you post the full stack trace? -- Thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
Yes, that is want I want. For now, what I've done works. Just getting the page requires the use of internal classes. I can't even think about how to get the component. Once this is included, then I can eliminate my hack. Norman Franke Answering Service for Directors, Inc. www.myasd.com On Jun 20, 2009, at 3:31 PM, Robert Zeigler wrote: Hm. What if you have a structure like: page component x bean edit form And you want the messages in component x (to make component x be reusable)? The way you've got it now, you'll always have to put the messages in the top level page. That said, I'm in the middle of: https://issues.apache.org/jira/browse/TAP5-692 Which, I think, is exactly what you're trying to accomplish... right? :) I have a bit more liberty than you in that I can tweak the framework to make this easier. :) What Im considering at the moment is having FieldValidatorDefaultSourceImpl push the overriding component resources onto the environment just before calling into the ValidationConstraintGenerator service (and popping it off immediately after), so the MessagesConstraintGenerator can access it. My only concern is whether any users have already pushed some instance of ComponentResources onto the environment and are counting on a particular instance to be available. I may wrap ComponentResources into a holder class to avoid this, but for now, I'm pushing ComponentResources directly. Anyway, hth. Robert On Jun 19, 2009, at 6/193:44 PM , Norman Franke wrote: On Jun 19, 2009, at 3:31 PM, Thiago H. de Paula Figueiredo wrote: Em Fri, 19 Jun 2009 15:26:44 -0300, Norman Franke nor...@myasd.com escreveu: No, the pages's properties. I figure I may want different settings on each page. Nice point. :) Seems like I'd need to know the page name and/or class for that. I don't. You can inject the Request and use the ComponentEventLinkEncoder service to get the logical name (xxx/yyy) that was requested and then use ComponentClassResolver.resolvePageNameToClassName() to get the class name. That seems more icky. Plus, you just get the page path. I think getting the actual Page would be better, since another implementation could use variables in the page instance. I did try it now, bug got a NPE when trying to resolvePageNameToClassName. So, I'll stick with what I have, I guess. If there isn't any better way to do it nor a JIRA about it, let's file one. Sure, feel free. Something along the lines if an injectable Page for the current page, or the current Component? You can do this yourself (all you need is to create an account at Apache's JIRA), but I already created it: https://issues.apache.org/jira/browse/TAP5-753 Thanks! I think it would be best if that was implemented. Norman Franke Answering Service for Directors, Inc. www.myasd.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
On Jun 18, 2009, at 8:11 PM, Thiago H. de Paula Figueiredo wrote: Em Thu, 18 Jun 2009 19:45:54 -0300, Norman Franke nor...@myasd.com escreveu: Thanks! You're welcome! The ValidationConstraintGenerator may work. Being new to T5 and all, I assume it's possible to @Inject the current page into my ValidationConstraintGenerator? Actually, I'd want the classpath to the .tml so I can get the .properties. By any chance are you trying to get the validation from the app.properties? I don't know how you would inject the page in a service. I'm trying to remeber some way to get access to the app.properties file, but I can't now. No, the pages's properties. I figure I may want different settings on each page. Not tested workaround suggestion: inject the ComponentSource service. Use its getPage(Class pageClass), using any page class as parameter, to retrievee a Component instance. Then invoke component.getComponentResources().getMessages() to get a Messages instance. Seems like I'd need to know the page name and/or class for that. I don't. If there isn't any better way to do it nor a JIRA about it, let's file one. Sure, feel free. Something along the lines if an injectable Page for the current page, or the current Component? Norman Franke Answering Service for Directors, Inc. www.myasd.com
Re: T5 + Hibernate + Hibernate Tools
Em Fri, 19 Jun 2009 15:26:44 -0300, Norman Franke nor...@myasd.com escreveu: No, the pages's properties. I figure I may want different settings on each page. Nice point. :) Seems like I'd need to know the page name and/or class for that. I don't. You can inject the Request and use the ComponentEventLinkEncoder service to get the logical name (xxx/yyy) that was requested and then use ComponentClassResolver.resolvePageNameToClassName() to get the class name. If there isn't any better way to do it nor a JIRA about it, let's file one. Sure, feel free. Something along the lines if an injectable Page for the current page, or the current Component? You can do this yourself (all you need is to create an account at Apache's JIRA), but I already created it: https://issues.apache.org/jira/browse/TAP5-753 -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
On Jun 19, 2009, at 3:31 PM, Thiago H. de Paula Figueiredo wrote: Em Fri, 19 Jun 2009 15:26:44 -0300, Norman Franke nor...@myasd.com escreveu: No, the pages's properties. I figure I may want different settings on each page. Nice point. :) Seems like I'd need to know the page name and/or class for that. I don't. You can inject the Request and use the ComponentEventLinkEncoder service to get the logical name (xxx/yyy) that was requested and then use ComponentClassResolver.resolvePageNameToClassName() to get the class name. That seems more icky. Plus, you just get the page path. I think getting the actual Page would be better, since another implementation could use variables in the page instance. I did try it now, bug got a NPE when trying to resolvePageNameToClassName. So, I'll stick with what I have, I guess. If there isn't any better way to do it nor a JIRA about it, let's file one. Sure, feel free. Something along the lines if an injectable Page for the current page, or the current Component? You can do this yourself (all you need is to create an account at Apache's JIRA), but I already created it: https://issues.apache.org/jira/browse/TAP5-753 Thanks! I think it would be best if that was implemented. Norman Franke Answering Service for Directors, Inc. www.myasd.com
T5 + Hibernate + Hibernate Tools
We have an existing database schema that's rather large. I've used Hibernate Tools to generate the .java entity files, complete with @Entity annotations so Hibernate picks them up automatically. That works very well. Next, I want to use BeanEditForm to edit the tables. I can't really add @Id, @NonVisual, or @Validate to the classes, since they'll be overwritten every time I re-generate the classes when I add or modify a table. What's the best way to do this? Is there some way to do this in a .properties file? Some fancy dynamic class augmentation scheme? I have over 100 tables, so something with minimal maintenance would be best. Norman Franke Answering Service for Directors, Inc. www.myasd.com
Re: T5 + Hibernate + Hibernate Tools
Em Thu, 18 Jun 2009 18:29:37 -0300, Norman Franke nor...@myasd.com escreveu: Next, I want to use BeanEditForm to edit the tables. I can't really add @Id, @NonVisual, or @Validate to the classes, since they'll be overwritten every time I re-generate the classes when I add or modify a table. Take a look at http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html, section Customizing the BeanModel. To add validation without touching entity class sources, take a look at the ValidationConstraintsGenerator interface. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
Thanks! The ValidationConstraintGenerator may work. Being new to T5 and all, I assume it's possible to @Inject the current page into my ValidationConstraintGenerator? Actually, I'd want the classpath to the .tml so I can get the .properties. Norman Franke Answering Service for Directors, Inc. www.myasd.com On Jun 18, 2009, at 5:40 PM, Thiago H. de Paula Figueiredo wrote: Em Thu, 18 Jun 2009 18:29:37 -0300, Norman Franke nor...@myasd.com escreveu: Next, I want to use BeanEditForm to edit the tables. I can't really add @Id, @NonVisual, or @Validate to the classes, since they'll be overwritten every time I re-generate the classes when I add or modify a table. Take a look at http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html , section Customizing the BeanModel. To add validation without touching entity class sources, take a look at the ValidationConstraintsGenerator interface. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
I think I figured it out: @InjectService(PageRenderQueue) private PageRenderQueue pageRenderQueue; Then in buildConstraints: Page page = pageRenderQueue.getRenderingPage(); Messages msgs = page.getRootComponent().getComponentResources().getMessages(); String myValue = msgs.get(myValue); From there, you get the Environment and peek(PropertyEditContext.class) to get the PropertyEditContext from which you can: getPropertyId(). This appears to work. Very cool! Norman Franke Answering Service for Directors, Inc. www.myasd.com On Jun 18, 2009, at 6:45 PM, Norman Franke wrote: Thanks! The ValidationConstraintGenerator may work. Being new to T5 and all, I assume it's possible to @Inject the current page into my ValidationConstraintGenerator? Actually, I'd want the classpath to the .tml so I can get the .properties. Norman Franke Answering Service for Directors, Inc. www.myasd.com On Jun 18, 2009, at 5:40 PM, Thiago H. de Paula Figueiredo wrote: Em Thu, 18 Jun 2009 18:29:37 -0300, Norman Franke nor...@myasd.com escreveu: Next, I want to use BeanEditForm to edit the tables. I can't really add @Id, @NonVisual, or @Validate to the classes, since they'll be overwritten every time I re-generate the classes when I add or modify a table. Take a look at http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html , section Customizing the BeanModel. To add validation without touching entity class sources, take a look at the ValidationConstraintsGenerator interface. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
Em Thu, 18 Jun 2009 19:45:54 -0300, Norman Franke nor...@myasd.com escreveu: Thanks! You're welcome! The ValidationConstraintGenerator may work. Being new to T5 and all, I assume it's possible to @Inject the current page into my ValidationConstraintGenerator? Actually, I'd want the classpath to the .tml so I can get the .properties. By any chance are you trying to get the validation from the app.properties? I don't know how you would inject the page in a service. I'm trying to remeber some way to get access to the app.properties file, but I can't now. Not tested workaround suggestion: inject the ComponentSource service. Use its getPage(Class pageClass), using any page class as parameter, to retrievee a Component instance. Then invoke component.getComponentResources().getMessages() to get a Messages instance. If there isn't any better way to do it nor a JIRA about it, let's file one. -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5 + Hibernate + Hibernate Tools
Em Thu, 18 Jun 2009 20:45:39 -0300, Norman Franke nor...@myasd.com escreveu: I think I figured it out: @InjectService(PageRenderQueue) private PageRenderQueue pageRenderQueue; By the way, very clever way to do it. :) Two comments: You could just @Inject private PageRenderQueue pageRenderQueue; @InjectService is meant to be used when there is more than one service instance for a given type. In addition, it is not advisable to use anything inside org.apache.tapestry5.internal, because it was created by Howard specifically to hold anything that Tapestry won't guarantee backward compatibility. Some internal classes were even removed between releases, but not a single not internal one. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5: Hibernate/Session question
Hello, I have an application state object(Visit) that is storing a hibernate entity object. In a page I ask for the visit.object.getchildobject.name and receive this error: [ERROR] hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed Can I not do this from application state objects? Thanks, --James
Re: T5: Hibernate/Session question
there are two possible solutions: first: you declare the collection for childobjects read not lazy second: you attach the parentobject to a new session and re-read the childobjects collection 2009/2/5 James Sherwood jsherw...@rgisolutions.com Hello, I have an application state object(Visit) that is storing a hibernate entity object. In a page I ask for the visit.object.getchildobject.name and receive this error: [ERROR] hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed Can I not do this from application state objects? Thanks, --James -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com
RE: T5: Hibernate/Session question
Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ Just making sure I was not doing something wrong:) --James -Original Message- From: Sven Homburg [mailto:hombu...@googlemail.com] Sent: February-05-09 2:23 PM To: Tapestry users Subject: Re: T5: Hibernate/Session question there are two possible solutions: first: you declare the collection for childobjects read not lazy second: you attach the parentobject to a new session and re-read the childobjects collection 2009/2/5 James Sherwood jsherw...@rgisolutions.com Hello, I have an application state object(Visit) that is storing a hibernate entity object. In a page I ask for the visit.object.getchildobject.name and receive this error: [ERROR] hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed Can I not do this from application state objects? Thanks, --James -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
Em Thu, 05 Feb 2009 15:59:53 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ One solution is to call session.lock(object, LockMode.NONE) before reading any property values. It associates the object with the given session, thus avoiding the LazyInstantiationException's. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: T5: Hibernate/Session question
Hello, I used session.update(Object) and it worked, is there any difference? --James -Original Message- From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] Sent: February-05-09 4:48 PM To: Tapestry users Subject: Re: T5: Hibernate/Session question Em Thu, 05 Feb 2009 15:59:53 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ One solution is to call session.lock(object, LockMode.NONE) before reading any property values. It associates the object with the given session, thus avoiding the LazyInstantiationException's. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
Em Thu, 05 Feb 2009 16:58:39 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Hello, Hi! I used session.update(Object) and it worked, is there any difference? session.update(Object) writes the object to the database, session.lock() not. Both associate the object to the session, so use one or the other depending on what you need. :) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
i prefer you to use the session.refresh 2009/2/5 James Sherwood jsherw...@rgisolutions.com Hello, I used session.update(Object) and it worked, is there any difference? --James -Original Message- From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] Sent: February-05-09 4:48 PM To: Tapestry users Subject: Re: T5: Hibernate/Session question Em Thu, 05 Feb 2009 15:59:53 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ One solution is to call session.lock(object, LockMode.NONE) before reading any property values. It associates the object with the given session, thus avoiding the LazyInstantiationException's. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com
Re: T5: Hibernate/Session question
Em Thu, 05 Feb 2009 17:07:24 -0300, Sven Homburg hombu...@googlemail.com escreveu: i prefer you to use the session.refresh This will overwrite your object, and sometimes you want it unchanged. As always, the best option depends on the context. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
ok ;-) 2009/2/5 Thiago H. de Paula Figueiredo thiag...@gmail.com Em Thu, 05 Feb 2009 17:07:24 -0300, Sven Homburg hombu...@googlemail.com escreveu: i prefer you to use the session.refresh This will overwrite your object, and sometimes you want it unchanged. As always, the best option depends on the context. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com
T5+Hibernate: Entity class id variables cannot have leading underscores
To use the simplified page activation context for a hibernate entity page (e.g., onActivate(Person p)...), it looks like the entity class' primary key id field's name must match VERBATIM the text that follows the word get in the getter (and set in the setter, probably). I.e., this won't work: @Id @GeneratedValue private Long _id; public Long getId() This fails because getId is not named get_id. I normally use underscore prefixes for my instance variables. This is failing in HibernateEntityValueEncoder on this line: propertyAdapter = propertyAccess.getAdapter(this.entityClass).getPropertyAdapter(idPropertyName); It looks for an idPropertyName _id and doesn't find one because according to the getter/setter pattern, the name is id. The propertyAdapter is then null which throws an NPE on line 79: Object id = typeCoercer.coerce(clientValue, propertyAdapter.getType()); Bill in Austin -- Without coding you have no product Without testing, no quality Without refactoring, no future - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5+Hibernate: Entity class id variables cannot have leading underscores
Hi, This has nothing to do with Tapestry. You have 2 options: 1) Use the @Column annotation on the _id field @Id @GeneratedValue @Column(name=id) private Long _id; 2) Annotate the accessor methods /Serge Bill Holloway wrote: To use the simplified page activation context for a hibernate entity page (e.g., onActivate(Person p)...), it looks like the entity class' primary key id field's name must match VERBATIM the text that follows the word get in the getter (and set in the setter, probably). I.e., this won't work: @Id @GeneratedValue private Long _id; public Long getId() This fails because getId is not named get_id. I normally use underscore prefixes for my instance variables. This is failing in HibernateEntityValueEncoder on this line: propertyAdapter = propertyAccess.getAdapter(this.entityClass).getPropertyAdapter(idPropertyName); It looks for an idPropertyName _id and doesn't find one because according to the getter/setter pattern, the name is id. The propertyAdapter is then null which throws an NPE on line 79: Object id = typeCoercer.coerce(clientValue, propertyAdapter.getType()); Bill in Austin -- Without coding you have no product Without testing, no quality Without refactoring, no future - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%2BHibernate%3A-Entity-class-id-variables-cannot-have-leading-underscores-tp20523653p20527276.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Hibernate and services
Hi, I have some tapestry-hibernate related questions: 1) if I have two concurrent services(A and B), each has Session injected. do A and B have their own transaction? 2) I have a table config that has a field 'nextID': 2.1 IDService has a method 'NextID()' which get the value from 'nextID' and increment it 2.2 AppendSerivce which uses IDService's NextID to get a number and assign to a new object, persist it if I have two instances of UserService(A and B) running, A will be successful in getting a new ID while B fails because it gets the same ID as A, any idea how to solve this problem? Thanks, Angelo -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-services-tp19985886p19985886.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: t5: Hibernate resultset with pagination
Hi Bill, This is a good idea, will give it a try, thanks. Angelo Bill Holloway wrote: Hi Angelo, I achieve custom paging for anything that uses a tapestry loop (or anything that needs a list per page) starting with this abstract class: public abstract class PagingResults T { protected int _page; -- View this message in context: http://www.nabble.com/t5%3A-Hibernate-resultset-with-pagination-tp19247842p19265676.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: t5: Hibernate resultset with pagination
not sure what you are trying achieve exactly paging, table, all can be simply generated even without grid but you'll need to print each column manualy, or dig deeper and use beanModel your self Davor Hrg On Mon, Sep 1, 2008 at 3:32 AM, Angelo Chen [EMAIL PROTECTED]wrote: Hi, I have a need to display some Hibernate resultset with pagination, but I can't use T5's grid. any hint how to do this in T5? thanks. Angelo -- View this message in context: http://www.nabble.com/t5%3A-Hibernate-resultset-with-pagination-tp19247842p19247842.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: t5: Hibernate resultset with pagination
Hi Angelo, I achieve custom paging for anything that uses a tapestry loop (or anything that needs a list per page) starting with this abstract class: public abstract class PagingResults T { protected int _page; protected int _resultsPerPage; public PagingResults (int resultsPerPage) { _page = 1; _resultsPerPage = resultsPerPage; } public ListT getCurrentPage () throws Exception { ListT pageOfResults = getResultsStartingAt( (_page - 1) * _resultsPerPage, _resultsPerPage); return pageOfResults; } public void incrementPage () { if (_page lastPage()) _page++; } public void decrementPage () { if (_page 1) _page--; } public void toLastPage () { _page = lastPage(); } public int lastPage () { return (int)Math.ceil((double)getTotalResults()/(double)_resultsPerPage); } public void reset () { _page = 1; } public int getPage () { return _page; } public int getResultsPerPage () { return _resultsPerPage; } public abstract ListT getResultsStartingAt (int start, int numToGet) throws Exception; public abstract long getTotalResults (); } This class' getCurrentPage() method returns a sublist of the total list for use in the loop, etc. Subclasses of this define the getResultsStartingAt() and the total number of results. I usually define subclasses of PagingResults as simple inner classes of my page/component classes where the services I need are injected. I have a companion component to this: public class Pager { @Parameter (required = true) private PagingResults _pagingResults; @Inject private Messages _messages; @Inject private ComponentResources _resources; void onActionFromToFirst () { _pagingResults.reset(); } void onActionFromToPrevious () { _pagingResults.decrementPage(); } void onActionFromToNext () { _pagingResults.incrementPage(); } void onActionFromToLast () { _pagingResults.toLastPage(); } public String getPagerInfo () { String s = ; int startInd = (_pagingResults.getPage() - 1) * _pagingResults.getResultsPerPage() + 1; long endInd = (startInd + _pagingResults.getResultsPerPage() - 1 _pagingResults.getTotalResults()) ? _pagingResults.getTotalResults() : startInd + _pagingResults.getResultsPerPage() - 1; s = startInd + - + endInd + + _messages.get(of) + + _pagingResults.getTotalResults(); return s; } public boolean getOnFirstPage () { return _pagingResults.getPage() == 1; } public boolean getOnLastPage () { return _pagingResults.getPage() == _pagingResults.lastPage(); } } The template for this Pager component is simple: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; div class=peoplepad_pager xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd; ${pagerInfo} nbsp; t:actionlink t:id=toFirst disabled=onFirstPage${message:first}/t:actionlink | t:actionlink t:id=toPrevious disabled=onFirstPagelt; ${message:previous.abbrev}/t:actionlink | t:actionlink t:id=toNext disabled=onLastPage${message:next} gt;/t:actionlink | t:actionlink t:id=toLast disabled=onLastPage${message:last}/t:actionlink /div In the page/component that uses all this I have a loop (typically) with source=pagingResults.currentPage. The around the list I place the pager component which takes the same PagingResults object as a parameter. Note this is not setup for Ajax interaction, just standard action links (Http gets). Cheers, Bill On Sun, Aug 31, 2008 at 8:32 PM, Angelo Chen [EMAIL PROTECTED] wrote: Hi, I have a need to display some Hibernate resultset with pagination, but I can't use T5's grid. any hint how to do this in T5? thanks. Angelo -- View this message in context: http://www.nabble.com/t5%3A-Hibernate-resultset-with-pagination-tp19247842p19247842.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Bill @ PeoplePad - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
t5: Hibernate resultset with pagination
Hi, I have a need to display some Hibernate resultset with pagination, but I can't use T5's grid. any hint how to do this in T5? thanks. Angelo -- View this message in context: http://www.nabble.com/t5%3A-Hibernate-resultset-with-pagination-tp19247842p19247842.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Hibernate OneToMany: Works in 5.0.11, Fails in 12, 13, 14-SNAPSHOT
Hello. I have 2 entities with a parent-child relationship. Client is the parent, and Project is the child. In 5.0.11 each Project entity is written to the (mysql) DB correctly with its client's ID, but in 5.0.12+ each Project's client_id is zero. I applied the following source code changes to upgrade from 5.0.11: * Changed import statements to reflect the renamed tapestry5 package. In AppModule.java: * Changed TapestryConstants.SUPPORTED_LOCALES_SYMBOL to SymbolConstants.SUPPORTED_LOCALES * Changed TapestryConstants.PRODUCTION_MODE_SYMBOL to SymbolConstants.PRODUCTION_MODE No other changes were made. I then changed the Tapestry version in pom.xml and fired it up with mvn jetty:run. Are there additional code or config changes that are required to keep this functionality working in 5.0.12+? Many thanks for your help! Jim -- HbAction.java: package net.bernatowicz.tapestry.pages; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Session; import java.util.Date; import java.util.ArrayList; import java.text.SimpleDateFormat; import java.text.ParseException; import net.bernatowicz.tapestry.entities.Hello; import net.bernatowicz.tapestry.entities.Client; import net.bernatowicz.tapestry.entities.YesNo; import net.bernatowicz.tapestry.entities.Project; public class HbAction { @Inject private Session _session; private Hello current; public void onAction() { Hello h = new Hello(); h.setCreatedOn(new Date()); h.setMessage(Hello); _session.save(h); ArrayList clientProjects = new ArrayList(); // Client is the parent: SimpleDateFormat sdf = new SimpleDateFormat(MM/dd/); Client c = new Client(); c.setActive(YesNo.YES); c.setName(InfiNet Marketing Group, Inc.); _session.save(c); // Project (1) is a child: Project p = new Project(); p.setActive(YesNo.YES); p.setClient(c); try { p.setDueDate(sdf.parse(04/01/2008)); } catch (ParseException e) { e.printStackTrace(); } p.setName(Redesign Woodlyn Sales Website); p.setSortKey(9); _session.save(p); clientProjects.add(p); // Project (2) is another child: p = new Project(); p.setActive(YesNo.YES); p.setClient(c); try { p.setDueDate(sdf.parse(4/15/08)); } catch (ParseException e) { e.printStackTrace(); } p.setName(Do Taxes); p.setSortKey(2); clientProjects.add(p); _session.save(p); c.setProjects(clientProjects); _session.save(c); } public List getList() { return _session.createCriteria(Hello.class).list(); } public Hello getCurrent() { return current; } public void setCurrent(Hello current) { this.current = current; } } -- Client.java: package net.bernatowicz.tapestry.entities; import javax.persistence.*; import java.util.*; import java.io.Serializable; @Entity @Table(name = client) public class Client implements Serializable { public Client() { created = new Date(); } @Id @GeneratedValue @Column(name = client_id) private long id; @Column(name = name, length = 50) private String name; @Column(name = active) private YesNo active; @Column(name = created) private Date created; @Column(name = updated) private Date updated; @OneToMany( targetEntity = Project.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER ) @JoinColumn(name = client_id) @org.hibernate.annotations.Cascade( value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN ) @org.hibernate.annotations.IndexColumn(name = sort_key) private List projects = new ArrayList(); public long getId() { return id; } public String getName() { return name; } public void setName(String name) { this.name = name; updated = new Date(); } public YesNo getActive() { return active; } public void setActive(YesNo active) { this.active = active; updated = new Date(); } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; updated = new Date(); } public Date getUpdated() { return updated; } public void setUpdated(Date updated) { this.updated = updated; } public List getProjects() { return projects; } public void setProjects(List projects) { this.projects = projects; } public long getId2() { return id; } } -- Project.java: package net.bernatowicz.tapestry.entities;
Re: T5: Hibernate OneToMany: Works in 5.0.11, Fails in 12, 13, 14-SNAPSHOT
you have to add a @CommitAfter in the method where update takes place, or do a commit, there is a change in default action from commit to abort, it's in the doc. bernatowicz wrote: Hello. I have 2 entities with a parent-child relationship. Client is the parent, and Project is the child. In 5.0.11 each Project entity is written to the (mysql) DB correctly with its client's ID, but in 5.0.12+ each Project's client_id is zero. I applied the following source code changes to upgrade from 5.0.11: * Changed import statements to reflect the renamed tapestry5 package. In AppModule.java: * Changed TapestryConstants.SUPPORTED_LOCALES_SYMBOL to SymbolConstants.SUPPORTED_LOCALES * Changed TapestryConstants.PRODUCTION_MODE_SYMBOL to SymbolConstants.PRODUCTION_MODE No other changes were made. I then changed the Tapestry version in pom.xml and fired it up with mvn jetty:run. Are there additional code or config changes that are required to keep this functionality working in 5.0.12+? Many thanks for your help! Jim -- HbAction.java: package net.bernatowicz.tapestry.pages; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Session; import java.util.Date; import java.util.ArrayList; import java.text.SimpleDateFormat; import java.text.ParseException; import net.bernatowicz.tapestry.entities.Hello; import net.bernatowicz.tapestry.entities.Client; import net.bernatowicz.tapestry.entities.YesNo; import net.bernatowicz.tapestry.entities.Project; public class HbAction { @Inject private Session _session; private Hello current; public void onAction() { Hello h = new Hello(); h.setCreatedOn(new Date()); h.setMessage(Hello); _session.save(h); ArrayList clientProjects = new ArrayList(); // Client is the parent: SimpleDateFormat sdf = new SimpleDateFormat(MM/dd/); Client c = new Client(); c.setActive(YesNo.YES); c.setName(InfiNet Marketing Group, Inc.); _session.save(c); // Project (1) is a child: Project p = new Project(); p.setActive(YesNo.YES); p.setClient(c); try { p.setDueDate(sdf.parse(04/01/2008)); } catch (ParseException e) { e.printStackTrace(); } p.setName(Redesign Woodlyn Sales Website); p.setSortKey(9); _session.save(p); clientProjects.add(p); // Project (2) is another child: p = new Project(); p.setActive(YesNo.YES); p.setClient(c); try { p.setDueDate(sdf.parse(4/15/08)); } catch (ParseException e) { e.printStackTrace(); } p.setName(Do Taxes); p.setSortKey(2); clientProjects.add(p); _session.save(p); c.setProjects(clientProjects); _session.save(c); } public List getList() { return _session.createCriteria(Hello.class).list(); } public Hello getCurrent() { return current; } public void setCurrent(Hello current) { this.current = current; } } -- Client.java: package net.bernatowicz.tapestry.entities; import javax.persistence.*; import java.util.*; import java.io.Serializable; @Entity @Table(name = client) public class Client implements Serializable { public Client() { created = new Date(); } @Id @GeneratedValue @Column(name = client_id) private long id; @Column(name = name, length = 50) private String name; @Column(name = active) private YesNo active; @Column(name = created) private Date created; @Column(name = updated) private Date updated; @OneToMany( targetEntity = Project.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER ) @JoinColumn(name = client_id) @org.hibernate.annotations.Cascade( value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN ) @org.hibernate.annotations.IndexColumn(name = sort_key) private List projects = new ArrayList(); public long getId() { return id; } public String getName() { return name; } public void setName(String name) { this.name = name; updated = new Date(); } public YesNo getActive() { return active; } public void setActive(YesNo active) { this.active = active; updated = new Date(); } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; updated = new Date(); } public Date getUpdated() { return updated; }
T5 - Hibernate - Transaction confusion
Hi, I'm trying to understand how transactions should be handled with the @CommitAfter annotation. I have a normal service interface (FormDAO) that is annotated with commit afters, but what happens when Pseudo code: void onSave() { formDAO.saveForm(form); formDAO.updateValues(form, user); } and the later call to formDAO throws an exception? Is the first method's transaction also rolled back, even if both methods have their own @CommitAfter annotations? The documentation doesn't specify whether the transaction is rolled back if there is one successfull @CommitAfter and one failed. Is the correct approach to wrap multiple service calls in to one and annotate only this? -99 -- View this message in context: http://www.nabble.com/T5---Hibernate---Transaction-confusion-tp18826235p18826235.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 - Hibernate - Transaction confusion
I think it rolls back only updateValues. I'd prefer to put several method calls under one transaction. 9902468 wrote: Hi, I'm trying to understand how transactions should be handled with the @CommitAfter annotation. I have a normal service interface (FormDAO) that is annotated with commit afters, but what happens when Pseudo code: void onSave() { formDAO.saveForm(form); formDAO.updateValues(form, user); } and the later call to formDAO throws an exception? Is the first method's transaction also rolled back, even if both methods have their own @CommitAfter annotations? The documentation doesn't specify whether the transaction is rolled back if there is one successfull @CommitAfter and one failed. Is the correct approach to wrap multiple service calls in to one and annotate only this? -99 -- View this message in context: http://www.nabble.com/T5---Hibernate---Transaction-confusion-tp18826235p18826695.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 - Hibernate - Transaction confusion
I read the source code and it seems that the @CommitAfter really is used to mark the method and then each method is decorated: thus each method call gets committed separately. Am I right? -99 9902468 wrote: Hi, I'm trying to understand how transactions should be handled with the @CommitAfter annotation. I have a normal service interface (FormDAO) that is annotated with commit afters, but what happens when Pseudo code: void onSave() { formDAO.saveForm(form); formDAO.updateValues(form, user); } and the later call to formDAO throws an exception? Is the first method's transaction also rolled back, even if both methods have their own @CommitAfter annotations? The documentation doesn't specify whether the transaction is rolled back if there is one successfull @CommitAfter and one failed. Is the correct approach to wrap multiple service calls in to one and annotate only this? -99 -- View this message in context: http://www.nabble.com/T5---Hibernate---Transaction-confusion-tp18826235p18826733.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Is the hibernate service initialized at all? When Tapestry starts it lists all known services, is Hibernate in that list? - 99 photos-4 wrote: Thanks for your help, but so far no joy: Quoting 9902468 [EMAIL PROTECTED]: And of course, check that you have Hibernate and hibernate annotation in your libraries, they are NOT included automatically by maven if maven is used. The libraries appear in my repository and appear under sources in the Eclipse Run Configuration. Tapestry should be quite verbose about hibernate if tapestry is configured to run in debug mode: http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html add: I placed -Dtapestry.production-mode=false on the command line, which, according to the docs, does the same thing. I see no output about Hibernate at all. It never gets mentioned... Also see that your entities are in correct place (same root package as pages and components, in entities package.) src/main/java/uk.bl.dlportal.entities src/main/java/uk.bl.dlportal.components src/main/java/uk.bl.dlportal.pages looks ok to me. Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign keys? (Change to hibernate config.) You should be able to see that Hibernate starts in the logs and maps User etc. classes. Remember to configure your Log4J or what ever logging u use to debug. I added some lines to log4j.properties to turn on hibernate logging (debug), but I see no output - just the usual Tapestry debug output that I've seen before. I'm really stumped... :-( Hibernate never gets called and yet everything appears to be in place. p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18684648.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Quoting 9902468 [EMAIL PROTECTED]: Is the hibernate service initialized at all? When Tapestry starts it lists all known services, is Hibernate in that list? - 99 It looks like it: ... FieldValidationSupport: DEFINED FieldValidatorDefaultSource: DEFINED FieldValidatorSource: DEFINED FormSupport: DEFINED HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED HiddenFieldLocationRules: DEFINED HttpServletRequest: DEFINED HttpServletRequestHandler: VIRTUAL IgnoredPathsFilter: DEFINED InjectionProvider: DEFINED InternalRequestGlobals: VIRTUAL LinkFactory: DEFINED ... I still haven't figured out what is going on. I see no evidence of Hibernate ever being called. Are any Hibernate services missing from the above list? p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Check also that you have the mysql-connector-java-5.1.6.jar or similar in your libraries. I have the following list: FieldValidatorSource: DEFINED FormDAO: DEFINED FormSupport: DEFINED FreeMarkerService: DEFINED FulfillmentDAO: DEFINED GoogleMapService: DEFINED HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED HiddenFieldLocationRules: DEFINED HiveMind: DEFINED HttpServletRequest: DEFINED HttpServletRequestHandler: VIRTUAL IgnoredPathsFilter: DEFINED So that one should be ok. Is the page that you are testing with _really_ calling session.something? Tapestry lazy loads everything so Hibernate is not really initialized without the call. Can we have the stack trace? - 99 photos-4 wrote: Quoting 9902468 [EMAIL PROTECTED]: Is the hibernate service initialized at all? When Tapestry starts it lists all known services, is Hibernate in that list? - 99 It looks like it: ... FieldValidationSupport: DEFINED FieldValidatorDefaultSource: DEFINED FieldValidatorSource: DEFINED FormSupport: DEFINED HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED HiddenFieldLocationRules: DEFINED HttpServletRequest: DEFINED HttpServletRequestHandler: VIRTUAL IgnoredPathsFilter: DEFINED InjectionProvider: DEFINED InternalRequestGlobals: VIRTUAL LinkFactory: DEFINED ... I still haven't figured out what is going on. I see no evidence of Hibernate ever being called. Are any Hibernate services missing from the above list? p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18685754.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at $RequestHandler_11b68bd4ff8.service($RequestHandler_11b68bd4ff8.java) at org.apache.tapestry5.services.TapestryModule$11.service(TapestryModule.java:918) at
Re: [T5]: Hibernate question - session is null
its look like, that your Security class is only a helper class and no page component. in such classes the @Inject annotation doesnt work 2008/7/28 [EMAIL PROTECTED] Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84) at org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:75) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at
Re: [T5]: Hibernate question - session is null
Yep, Injection works only in page and component classes that live the ordinary Page or component lifecycle, and are requested from the web. :) Move the session to a real page and have that util to take the session as parameter, or even better move your logic to service that a page can use. (SecurityService perhaps?) - 99 Sven Homburg wrote: its look like, that your Security class is only a helper class and no page component. in such classes the @Inject annotation doesnt work 2008/7/28 [EMAIL PROTECTED] Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
Re: [T5]: Hibernate question - thank you!
Ok. Great gadzooks! Now I see. Thanks to you and Sven. (I knew this was going to be obvious once pointed out!) p. Quoting 9902468 [EMAIL PROTECTED]: Yep, Injection works only in page and component classes that live the ordinary Page or component lifecycle, and are requested from the web. :) Move the session to a real page and have that util to take the session as parameter, or even better move your logic to service that a page can use. (SecurityService perhaps?) - 99 Sven Homburg wrote: its look like, that your Security class is only a helper class and no page component. in such classes the @Inject annotation doesnt work 2008/7/28 [EMAIL PROTECTED] Ok, I have just checked. I have mysql-connector-java-5.1.5.jar in the maven repository. Code is: - package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); Criteria c = session.createCriteria(User.class); List result = c.list(); System.out.println(SESSION +session); return null; } public static Security getSecurity() { return security; } } Stack trace is: 84.73% unrealized services (111/131) [INFO] mortbay.log Started [EMAIL PROTECTED]:8080 [DEBUG] AppModule.TimingFilter Creating service 'TimingFilter'. [DEBUG] AppModule.TimingFilter Invoking method uk.bl.dlportal.services.AppModule.buildTimingFilter(Logger) (at AppModule.java:71). [INFO] AppModule.TimingFilter Request time: 4846 ms [INFO] AppModule.TimingFilter Request time: 0 ms [INFO] AppModule.TimingFilter Request time: 16 ms SESSION null [INFO] AppModule.TimingFilter Request time: 251 ms [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: org.apache.tapestry5.runtime.ComponentEventException org.apache.tapestry5.runtime.ComponentEventException [at context:Index.tml, line 7, column 28] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1042) at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:67) at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at org.apache.tapestry5.services.TapestryModule$37.handle(TapestryModule.java:1987) at $ComponentEventRequestHandler_11b68bd5062.handle($ComponentEventRequestHandler_11b68bd5062.java) at $ComponentEventRequestHandler_11b68bd500b.handle($ComponentEventRequestHandler_11b68bd500b.java) at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:135) at $Dispatcher_11b68bd500e.dispatch($Dispatcher_11b68bd500e.java) at $Dispatcher_11b68bd5000.dispatch($Dispatcher_11b68bd5000.java) at org.apache.tapestry5.services.TapestryModule$12.service(TapestryModule.java:938) at uk.bl.dlportal.services.AppModule$1.service(AppModule.java:84) at $RequestFilter_11b68bd4fff.service($RequestFilter_11b68bd4fff.java) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.LocalizationFilter.service(LocalizationFilter.java:42) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:586) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79) at $RequestHandler_11b68bd5001.service($RequestHandler_11b68bd5001.java) at org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93) at
Re: [T5]: Hibernate question - session is null
Hi, I also had some trouble configuring hibernate, my session was also null. After searching for a while I found this tutorial: http://linuxboy.javaeye.com/blog/68311 Since I dont use a DAO, my code looks something like the following. my db entity: ... import org.hibernate.Session; @Entity @Table(name = EVENT) public class EventDBEntity { public EventDBEntity() {} public EventDBEntity(Session session) {_session = session;} @Transient private Session _session; // more stuff here.. methods to access the db ... in my appmodule.java: ... public static void bind(ServiceBinder binder) { binder.bind(TourDBEntity.class); } ... then I call an @Inject on the db-entity: ... // db entity object @Inject private EventDBEntity _dbEntity; // now tapestry injects the hibernate session in my _dbEntity ... Hope this helps! Greetings, Mark -- Mark Weißenberg Tel. +49 228 9599630 startext Unternehmensberatung GmbH Kennedyallee 2, D-53175 Bonn Geschäftsführer Paul Bantzer, HRB Bonn 2741 Sitz der Gesellschaft: Bonn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Check that the @Inject private Session session; session is org.hibernate.Session. - 99 photos-4 wrote: I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18650658.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Tapestry should be quite verbose about hibernate if tapestry is configured to run in debug mode: http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html add: //This is the time in seconds that Tapestry waits before checking if a file is modified //Use a big number in production to imporve perfomance. configuration.add(SymbolConstants.FILE_CHECK_INTERVAL, 1 s); // 600 to production! // The factory default is true but during the early stages of an application // overriding to false is a good idea. In addition, this is often overridden // on the command line as -Dtapestry.production-mode=false configuration.add(SymbolConstants.PRODUCTION_MODE, false); to your AppModule.java's public static void contributeApplicationDefaults(MappedConfigurationString, String configuration) { method. Also see that your entities are in correct place (same root package as pages and components, in entities package.) Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign keys? (Change to hibernate config.) You should be able to see that Hibernate starts in the logs and maps User etc. classes. Remember to configure your Log4J or what ever logging u use to debug. - 99 photos-4 wrote: I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18651481.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
And of course, check that you have Hibernate and hibernate annotation in your libraries, they are NOT included automatically by maven if maven is used. - 99 photos-4 wrote: I'm using Eclipse. The XML config appears in target/classes and appears to be in the classpath. I'm afraid I'm rather new to Tap 5 and also to Hibernate. I'm just following what is in the Tutorial. Unfortunately the session is still coming out as null. Is there anywhere I can see that Tapestry is actually using Hibernate as a service? I get the following in the console when I start my application: ... HibernateEntityPackageManager: DEFINED HibernateSessionManager: DEFINED HibernateSessionSource: DEFINED HibernateTransactionDecorator: DEFINED ... Quoting Andreas Andreou [EMAIL PROTECTED]: Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-T5-%3A-Hibernate-question-tp18634071p18651522.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Quoting 9902468 [EMAIL PROTECTED]: Check that the @Inject private Session session; session is org.hibernate.Session. - 99 It is. I notice that when I switch on the mysql log that no attempt is ever made to access the db. Is there any kind of logging I can switch on from Tapestry (or maybe Hibernate) to tell me what is going on? (I am quite sure the xml file is correct and in the classpath, so I am running out of ideas! Although it must be something simple as these things usually are). session is always null when this code is run. Code and XML below: package uk.bl.dlportal.pages.util; import java.util.List; import org.apache.tapestry5.ioc.annotations.Inject; import org.hibernate.Query; import org.hibernate.Session; import uk.bl.dlportal.entities.User; public class Security { @Inject private Session session; private final static Security security = new Security(); public User authenticate(String userName, String password) { System.out.println(SESSION +session); List result = session.createCriteria(User.class).list(); return null; } public static Security getSecurity() { return security; } } XML hibernate.cfg.xml is in src/main/resources: !DOCTYPE hibernate-configuration PUBLIC -//Hibernate/Hibernate Configuration DTD 3.0//EN http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd; hibernate-configuration session-factory property name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property property name=hibernate.connection.urljdbc:mysql://localhost:3306/dlportal/property property name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property property name=hibernate.connection.usernameroot/property property name=hibernate.connection.passwordadmin/property property name=hbm2ddl.autoupdate/property property name=hibernate.show_sqltrue/property property name=hibernate.format_sqltrue/property /session-factory /hibernate-configuration - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question - session is null
Thanks for your help, but so far no joy: Quoting 9902468 [EMAIL PROTECTED]: And of course, check that you have Hibernate and hibernate annotation in your libraries, they are NOT included automatically by maven if maven is used. The libraries appear in my repository and appear under sources in the Eclipse Run Configuration. Tapestry should be quite verbose about hibernate if tapestry is configured to run in debug mode: http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html add: I placed -Dtapestry.production-mode=false on the command line, which, according to the docs, does the same thing. I see no output about Hibernate at all. It never gets mentioned... Also see that your entities are in correct place (same root package as pages and components, in entities package.) src/main/java/uk.bl.dlportal.entities src/main/java/uk.bl.dlportal.components src/main/java/uk.bl.dlportal.pages looks ok to me. Also perhaps use org.hibernate.dialect.MySQLInnoDBDialect to support foreign keys? (Change to hibernate config.) You should be able to see that Hibernate starts in the logs and maps User etc. classes. Remember to configure your Log4J or what ever logging u use to debug. I added some lines to log4j.properties to turn on hibernate logging (debug), but I see no output - just the usual Tapestry debug output that I've seen before. I'm really stumped... :-( Hibernate never gets called and yet everything appears to be in place. p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[T5]: Hibernate question
I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5]: Hibernate question
Perhaps hibernate.cfg.xml isn't in your runtime classpath? Are you sure your IDE includes it to the output? On Thu, Jul 24, 2008 at 6:09 PM, [EMAIL PROTECTED] wrote: I am following the tutorial at http://tapestry.apache.org/tapestry5/tutorial1/forms2.html but I find that the session (supposedly injected) is null. I'm not sure how to proceed. Could someone point me to documents/better tutorials on how to use Tapestry with Hibernate? Thanks, p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] Hibernate integration problems/questions
From the documentation: The transaction will be committed when the method completes normally. The transaction will be aborted if the method throws a RuntimeException. The transaction will be committed if the method throws a checked exception (one listed in the throws clause of the method). And from the main page: Transactions are now aborted (no longer committed) at the end of each request: you must now explicitly commit the transaction if changes are to be saved. So either commit OR rollback should occur. I personally would like to use the model where checked exceptions would cause automatic rollback also. Is this a technical limitation or just chosen procedure? If chosen please elaborate. Brendan McNichols-2 wrote: Hi all, I have two questions/issues with tapestry-hibernate integration: 1) In my app, I am getting a java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0 exception (I am using MySQL, btw) after the site has been up for a while. I have tried several things to fix this (adding autoReconnect=true and tcpKeepAlive=true to the jdbc url and a few other things related to connection pooling) to no avail. Googling this exception led to a couple of sites indicating that this problem most likely has to do with leaving a connection open by not doing a commit on the transaction, even after queries. I have faithfully used the @CommitAfter annotation on all of my updates/deletes, but not on queries. Should I be using @CommitAfter even for queries? The example at http://tapestry.apache.org/tapestry5/tapestry-hibernate/userguide.html seems to indicate not (because there is no @CommitAfter on the findByName method). Would there be any other reason that a transaction is left open without a commit? Has anyone else experienced this problem, and if so, how did you fix it? 2) Is there a good reason why @CommitAfter does a commit even when the method throws a checked exception? I would like my business handling methods to rollback the transaction if the method does not complete normally. I really want to use a checked exception so the caller is forced to catch it. Thanks in advance for any help! -- View this message in context: http://www.nabble.com/-T5--Hibernate-integration-problems-questions-tp18595793p18608207.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [T5] Hibernate integration problems/questions
Hi, It's not a technical limitation, but if I recall correctly it mirrors the way EJB handles exceptions. I'm actually surprised this is not configurable... -Filip On 2008-07-23 13:12, 9902468 wrote: From the documentation: The transaction will be committed when the method completes normally. The transaction will be aborted if the method throws a RuntimeException. The transaction will be committed if the method throws a checked exception (one listed in the throws clause of the method). And from the main page: Transactions are now aborted (no longer committed) at the end of each request: you must now explicitly commit the transaction if changes are to be saved. So either commit OR rollback should occur. I personally would like to use the model where checked exceptions would cause automatic rollback also. Is this a technical limitation or just chosen procedure? If chosen please elaborate. Brendan McNichols-2 wrote: Hi all, I have two questions/issues with tapestry-hibernate integration: 1) In my app, I am getting a java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0 exception (I am using MySQL, btw) after the site has been up for a while. I have tried several things to fix this (adding autoReconnect=true and tcpKeepAlive=true to the jdbc url and a few other things related to connection pooling) to no avail. Googling this exception led to a couple of sites indicating that this problem most likely has to do with leaving a connection open by not doing a commit on the transaction, even after queries. I have faithfully used the @CommitAfter annotation on all of my updates/deletes, but not on queries. Should I be using @CommitAfter even for queries? The example at http://tapestry.apache.org/tapestry5/tapestry-hibernate/userguide.html seems to indicate not (because there is no @CommitAfter on the findByName method). Would there be any other reason that a transaction is left open without a commit? Has anyone else experienced this problem, and if so, how did you fix it? 2) Is there a good reason why @CommitAfter does a commit even when the method throws a checked exception? I would like my business handling methods to rollback the transaction if the method does not complete normally. I really want to use a checked exception so the caller is forced to catch it. Thanks in advance for any help! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[T5] Hibernate integration problems/questions
Hi all, I have two questions/issues with tapestry-hibernate integration: 1) In my app, I am getting a java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0 exception (I am using MySQL, btw) after the site has been up for a while. I have tried several things to fix this (adding autoReconnect=true and tcpKeepAlive=true to the jdbc url and a few other things related to connection pooling) to no avail. Googling this exception led to a couple of sites indicating that this problem most likely has to do with leaving a connection open by not doing a commit on the transaction, even after queries. I have faithfully used the @CommitAfter annotation on all of my updates/deletes, but not on queries. Should I be using @CommitAfter even for queries? The example at http://tapestry.apache.org/tapestry5/tapestry-hibernate/userguide.html seems to indicate not (because there is no @CommitAfter on the findByName method). Would there be any other reason that a transaction is left open without a commit? Has anyone else experienced this problem, and if so, how did you fix it? 2) Is there a good reason why @CommitAfter does a commit even when the method throws a checked exception? I would like my business handling methods to rollback the transaction if the method does not complete normally. I really want to use a checked exception so the caller is forced to catch it. Thanks in advance for any help!
Re: T5: Hibernate and services
Dependends on the version of Tapestry. Earlier versions included an automatic commit. On Thu, Jun 26, 2008 at 7:44 PM, Angelo Chen [EMAIL PROTECTED] wrote: Hi, As what I understand now that transaction has to be committed to persist the objects, following is a diapatcher, there is no commit, but the new PageLog got persisted too, any idea? thanks, Angelo public class LoggingDispatcher implements Dispatcher { private final HibernateSessionManager sessionManager; public LoggingDispatcher(ApplicationStateManager asm, RequestGlobals requests, HibernateSessionManager sessionManager, IPLookup ipLookup) { this.sessionManager = sessionManager; } public boolean dispatch(Request request, Response response) throws IOException { PageLog log = new PageLog(); sessionManager.getSession().save(log); return false; } -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-services-tp18147187p18147187.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and services
Hi, This is version 5.0.13, and I turned off the auto commit, property name=hibernate.connection.autocommitfalse/property Howard Lewis Ship wrote: Dependends on the version of Tapestry. Earlier versions included an automatic commit. On Thu, Jun 26, 2008 at 7:44 PM, Angelo Chen [EMAIL PROTECTED] wrote: Hi, As what I understand now that transaction has to be committed to persist the objects, following is a diapatcher, there is no commit, but the new PageLog got persisted too, any idea? thanks, Angelo public class LoggingDispatcher implements Dispatcher { private final HibernateSessionManager sessionManager; public LoggingDispatcher(ApplicationStateManager asm, RequestGlobals requests, HibernateSessionManager sessionManager, IPLookup ipLookup) { this.sessionManager = sessionManager; } public boolean dispatch(Request request, Response response) throws IOException { PageLog log = new PageLog(); sessionManager.getSession().save(log); return false; } -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-services-tp18147187p18147187.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-services-tp18147187p18155441.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Hibernate and services
Hi, As what I understand now that transaction has to be committed to persist the objects, following is a diapatcher, there is no commit, but the new PageLog got persisted too, any idea? thanks, Angelo public class LoggingDispatcher implements Dispatcher { private final HibernateSessionManager sessionManager; public LoggingDispatcher(ApplicationStateManager asm, RequestGlobals requests, HibernateSessionManager sessionManager, IPLookup ipLookup) { this.sessionManager = sessionManager; } public boolean dispatch(Request request, Response response) throws IOException { PageLog log = new PageLog(); sessionManager.getSession().save(log); return false; } -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-services-tp18147187p18147187.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Hibernate warning
Hi, This is an old problem that I was not able to fix, applications runs, but always get this error [WARN] AnnotationBinder Package not found or wo package-info.java: org.bfe.sample.t5.entities I do have a hibernate.cfg.xml as follow and it works well: hibernate-configuration session-factory property name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property !-- List of annotated classes-- mapping class=org.bfe.sample.t5.entities.Usr/ /session-factory /hibernate-configuration I do remember that somebody suggests putting a package-info.java in the entitiies directory, but what needed to be listed? Thanks, Angelo -- View this message in context: http://www.nabble.com/T5%EF%BC%9A-Hibernate-warning-tp18125776p18125776.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate warning
It's just a warning, not an error, you can safely ignore this one. =) On Wed, Jun 25, 2008 at 11:13 PM, Angelo Chen [EMAIL PROTECTED] wrote: Hi, This is an old problem that I was not able to fix, applications runs, but always get this error [WARN] AnnotationBinder Package not found or wo package-info.java: org.bfe.sample.t5.entities I do have a hibernate.cfg.xml as follow and it works well: hibernate-configuration session-factory property name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property !-- List of annotated classes-- mapping class=org.bfe.sample.t5.entities.Usr/ /session-factory /hibernate-configuration I do remember that somebody suggests putting a package-info.java in the entitiies directory, but what needed to be listed? Thanks, Angelo -- View this message in context: http://www.nabble.com/T5%EF%BC%9A-Hibernate-warning-tp18125776p18125776.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using Hibernate interceptors with T5-Hibernate
Hi! We have few existing Hibernate interceptors and we successfully added those to the Hibernate configuration, but the question is how to inject services / application states to those interceptors. This cannot be done with autobind because (According to Hibernate docs.) Hibernate interceptors must contain parameterless constructors that Hibernate uses when instantiates these classes. If interceptors are used the Hibernate way, then the lifecycle etc. are controlled by Hibernate, and T5 services cannot be used? How to solve this? - 99 Ps. If the answer is to use T5 decorators instead of Hibernate interceptors could someone post a short example how to decorate a service so that all classes implementing specific interface that come to service as parameters are updated to include correct, let's say, update timestamp? Or better yet include it anyway so I can implement it that way in the future :) Thanks! (I did read the IOC docs but couldn't quite picture how to achieve this, as I can target multiple services, but how do I intercept all those entities that go as parameters to service _methods_?) -- View this message in context: http://www.nabble.com/Using-Hibernate-interceptors-with-T5-Hibernate-tp18002714p18002714.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Hibernate interceptors with T5-Hibernate
thats my (ugly) solution http://pastebin.com/f731adbea 2008/6/19 9902468 [EMAIL PROTECTED]: Hi! We have few existing Hibernate interceptors and we successfully added those to the Hibernate configuration, but the question is how to inject services / application states to those interceptors. This cannot be done with autobind because (According to Hibernate docs.) Hibernate interceptors must contain parameterless constructors that Hibernate uses when instantiates these classes. If interceptors are used the Hibernate way, then the lifecycle etc. are controlled by Hibernate, and T5 services cannot be used? How to solve this? - 99 Ps. If the answer is to use T5 decorators instead of Hibernate interceptors could someone post a short example how to decorate a service so that all classes implementing specific interface that come to service as parameters are updated to include correct, let's say, update timestamp? Or better yet include it anyway so I can implement it that way in the future :) Thanks! (I did read the IOC docs but couldn't quite picture how to achieve this, as I can target multiple services, but how do I intercept all those entities that go as parameters to service _methods_?) -- View this message in context: http://www.nabble.com/Using-Hibernate-interceptors-with-T5-Hibernate-tp18002714p18002714.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- with regards Sven Homburg http://tapestry5-components.googlecode.com http://chenillekit.googlecode.com
Re: Using Hibernate interceptors with T5-Hibernate
Thanks, this is exactly what I ment! (What is the ugly part? =D ) Thanks also for the superb component (and then some) lib! -99 Sven Homburg wrote: thats my (ugly) solution http://pastebin.com/f731adbea 2008/6/19 9902468 [EMAIL PROTECTED]: Hi! We have few existing Hibernate interceptors and we successfully added those to the Hibernate configuration, but the question is how to inject services / application states to those interceptors. This cannot be done with autobind because (According to Hibernate docs.) Hibernate interceptors must contain parameterless constructors that Hibernate uses when instantiates these classes. If interceptors are used the Hibernate way, then the lifecycle etc. are controlled by Hibernate, and T5 services cannot be used? How to solve this? - 99 Ps. If the answer is to use T5 decorators instead of Hibernate interceptors could someone post a short example how to decorate a service so that all classes implementing specific interface that come to service as parameters are updated to include correct, let's say, update timestamp? Or better yet include it anyway so I can implement it that way in the future :) Thanks! (I did read the IOC docs but couldn't quite picture how to achieve this, as I can target multiple services, but how do I intercept all those entities that go as parameters to service _methods_?) -- View this message in context: http://www.nabble.com/Using-Hibernate-interceptors-with-T5-Hibernate-tp18002714p18002714.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- with regards Sven Homburg http://tapestry5-components.googlecode.com http://chenillekit.googlecode.com - best regards Sven -- View this message in context: http://www.nabble.com/Using-Hibernate-interceptors-with-T5-Hibernate-tp18002714p18005737.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Hibernate ValueEncoders
Hi, In Howard's blog, he mentioend: Automatic Hibernate ValueEncoders: Use an entity as a page or event context and what goes in the URL is the entity's id. Likewise, ids are turned back into entities when passed to event handler methods. What's really this? how to use it? Thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-ValueEncoders-tp16075835p16075835.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate ValueEncoders
Hi, It means that you can pass Hibernate entities around instead of ids. Example: void onActivate(Long id) { User user = session.get(User.class, id); } Long onPassivate() { return user.getId(); } becomes void onActivate(User user) { ... } User onPassivate() { return user; } And so forth. Of course this only works if you actually use tapestry-hibernate. :) -Filip On 2008-03-16 07:14, Angelo Chen wrote: Hi, In Howard's blog, he mentioend: Automatic Hibernate ValueEncoders: Use an entity as a page or event context and what goes in the URL is the entity's id. Likewise, ids are turned back into entities when passed to event handler methods. What's really this? how to use it? Thanks. A.C. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate warning
Angelo Chen wrote: I use Tapestry-Hibernate and it works very well, just I always see this warning in the log: [WARN] AnnotationBinder Package not found or wo package-info.java: : org.ust.test.t5.entities You can create a file called package-info.java (see [1] for details) in your package directory and the warning should disappear. Jesper [1] http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.4.1.1 -- Jesper Zedlitz Dept. for Computer Science, CAU of Kiel Room 1108Communication Systems Research Group Phone:+49-(0)431-880-7279 Christian-Albrechts-Platz 4 Fax: +49-(0)431-880-7615 24098 Kiel - Germany [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Hibernate warning
Hi, I use Tapestry-Hibernate and it works very well, just I always see this warning in the log: [WARN] AnnotationBinder Package not found or wo package-info.java: : org.ust.test.t5.entities -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-warning-tp15706803p15706803.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
this is now fixed for T5.0.11 I've updated wiki to reflect the change. Davor Hrg On Feb 8, 2008 2:55 PM, Davor Hrg [EMAIL PROTECTED] wrote: uh, oh, it seems I've found a small workarround, not a definitive fix, but the TreadSource works with it.. the wiki is updated http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread Davor Hrg On Feb 8, 2008 12:45 PM, Davor Hrg [EMAIL PROTECTED] wrote: this seems to be a JVM bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5025230 I tried it in Java 6 and code works just fine I'll look into it, an post a jira... also still trying to make a workarround for it Davor Hrg On Feb 8, 2008 1:29 AM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Davor, That explains my problem, this happens in 5.0.7 and 5.0.9, never tried it with 5.0.8 Davor Hrg wrote: I'm debuggin an example like yours, and although I called ThreadCleanupHub.cleanup() the list of listeners is empty... and HibernateSessionManager is not in it something is very wrong Davor Hrg -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15346983.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
that's good, i have been using ur work around for the 5.09 version. the strange thing about this bug is, sometimes it works even without that work around, but just to be sure, I use the work around all the time, will try that 5.0.11 when it is released. thanks. Davor Hrg wrote: this is now fixed for T5.0.11 I've updated wiki to reflect the change. Davor Hrg On Feb 8, 2008 2:55 PM, Davor Hrg [EMAIL PROTECTED] wrote: uh, oh, it seems I've found a small workarround, not a definitive fix, but the TreadSource works with it.. the wiki is updated http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread Davor Hrg On Feb 8, 2008 12:45 PM, Davor Hrg [EMAIL PROTECTED] wrote: this seems to be a JVM bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5025230 I tried it in Java 6 and code works just fine I'll look into it, an post a jira... also still trying to make a workarround for it Davor Hrg On Feb 8, 2008 1:29 AM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Davor, That explains my problem, this happens in 5.0.7 and 5.0.9, never tried it with 5.0.8 Davor Hrg wrote: I'm debuggin an example like yours, and although I called ThreadCleanupHub.cleanup() the list of listeners is empty... and HibernateSessionManager is not in it something is very wrong Davor Hrg -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15346983.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15433651.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
this seems to be a JVM bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5025230 I tried it in Java 6 and code works just fine I'll look into it, an post a jira... also still trying to make a workarround for it Davor Hrg On Feb 8, 2008 1:29 AM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Davor, That explains my problem, this happens in 5.0.7 and 5.0.9, never tried it with 5.0.8 Davor Hrg wrote: I'm debuggin an example like yours, and although I called ThreadCleanupHub.cleanup() the list of listeners is empty... and HibernateSessionManager is not in it something is very wrong Davor Hrg -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15346983.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
uh, oh, it seems I've found a small workarround, not a definitive fix, but the TreadSource works with it.. the wiki is updated http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread Davor Hrg On Feb 8, 2008 12:45 PM, Davor Hrg [EMAIL PROTECTED] wrote: this seems to be a JVM bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5025230 I tried it in Java 6 and code works just fine I'll look into it, an post a jira... also still trying to make a workarround for it Davor Hrg On Feb 8, 2008 1:29 AM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Davor, That explains my problem, this happens in 5.0.7 and 5.0.9, never tried it with 5.0.8 Davor Hrg wrote: I'm debuggin an example like yours, and although I called ThreadCleanupHub.cleanup() the list of listeners is empty... and HibernateSessionManager is not in it something is very wrong Davor Hrg -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15346983.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
Hi Andy, Thanks for the quick reply, based on that I modified it as follow: @Inject private HibernateSessionManager sessionManager; Object onSuccess() { final Long id = create.append(); sessionManager.commit(); new Thread(new Runnable() { public void run() { myThread.findMe(id); } }).start(); return null; } It seems working. A.c. Andy Huhn wrote: Hi Angelo, The MyCreate service creates a new record, but doesn't commit until after MyThread is started. The MyThread service automatically gets a different Hibernate Session, and thus can't see the record that hasn't been committed yet by the other session. I'm not that familiar with MySQL, but my guess is that the InnoDB engine supports transactions, while the MyISAM engine doesn't? If you want this record to be visible across two different threads, you must commit before you start the second thread. Or perhaps it's simpler not to use a second thread, and do everything in one session. Andy On Wed, 2008-02-06 at 22:33 -0800, Angelo Chen wrote: Hi, I have two services, namely MyCreate and MyThread, what they do is: -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15329490.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
you should call ThreadCleanupHub.cleanup() at the each thread you spawn for your self, or tapestry threaded resources will not get cleaned, and youl make a mem leak. tapestry uses ThreadLocal to store threaded services like Session, for example if any part of the code references session(calls a method) while it is executed from your thread new session for that thread will be created, and without calling ThreadCleanupHub.cleanup() inside that thread service On Feb 7, 2008 9:41 AM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Andy, Thanks for the quick reply, based on that I modified it as follow: @Inject private HibernateSessionManager sessionManager; Object onSuccess() { final Long id = create.append(); sessionManager.commit(); new Thread(new Runnable() { public void run() { myThread.findMe(id); } }).start(); return null; } It seems working. A.c. Andy Huhn wrote: Hi Angelo, The MyCreate service creates a new record, but doesn't commit until after MyThread is started. The MyThread service automatically gets a different Hibernate Session, and thus can't see the record that hasn't been committed yet by the other session. I'm not that familiar with MySQL, but my guess is that the InnoDB engine supports transactions, while the MyISAM engine doesn't? If you want this record to be visible across two different threads, you must commit before you start the second thread. Or perhaps it's simpler not to use a second thread, and do everything in one session. Andy On Wed, 2008-02-06 at 22:33 -0800, Angelo Chen wrote: Hi, I have two services, namely MyCreate and MyThread, what they do is: -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15329490.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
just added : http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread haven't tested it though :) Davor Hrg On Feb 7, 2008 11:51 AM, Davor Hrg [EMAIL PROTECTED] wrote: you should call ThreadCleanupHub.cleanup() at the each thread you spawn for your self, or tapestry threaded resources will not get cleaned, and youl make a mem leak. tapestry uses ThreadLocal to store threaded services like Session, for example if any part of the code references session(calls a method) while it is executed from your thread new session for that thread will be created, and without calling ThreadCleanupHub.cleanup() inside that thread service On Feb 7, 2008 9:41 AM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Andy, Thanks for the quick reply, based on that I modified it as follow: @Inject private HibernateSessionManager sessionManager; Object onSuccess() { final Long id = create.append(); sessionManager.commit(); new Thread(new Runnable() { public void run() { myThread.findMe(id); } }).start(); return null; } It seems working. A.c. Andy Huhn wrote: Hi Angelo, The MyCreate service creates a new record, but doesn't commit until after MyThread is started. The MyThread service automatically gets a different Hibernate Session, and thus can't see the record that hasn't been committed yet by the other session. I'm not that familiar with MySQL, but my guess is that the InnoDB engine supports transactions, while the MyISAM engine doesn't? If you want this record to be visible across two different threads, you must commit before you start the second thread. Or perhaps it's simpler not to use a second thread, and do everything in one session. Andy On Wed, 2008-02-06 at 22:33 -0800, Angelo Chen wrote: Hi, I have two services, namely MyCreate and MyThread, what they do is: -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15329490.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
I'm debuggin an example like yours, and although I called ThreadCleanupHub.cleanup() the list of listeners is empty... and HibernateSessionManager is not in it something is very wrong Davor Hrg On Feb 7, 2008 9:35 PM, Davor Hrg [EMAIL PROTECTED] wrote: you did'nt say if the entity is saved to db, if you call commit explicitely, you'll see changes in log, but the way the snippet works is you create entity, you save it to session you change entity... after your task is done, ThreadCleanupHub.cleanup() is called HibernateSessionManager is a listener for that and calls commit then. so your changes are writen to the database at the end, not every time you modify something or, am I missing sth ? Davor Hrg On Feb 7, 2008 4:42 PM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Davor, Thanks for your ThreadSource, it works and makes threaded tasks in T5 easier, I have included it in my app. however, in my case, the threaded service has insert and update in the same time: Doc doc = new Doc(); session.save(doc); doc.setTitle(test); in the Hibernate log, it has : insert into doc... but you can't see update and commit. if I add a sessionManager.commit() then I can see: update doc set... [DEBUG] JDBCTransaction committed JDBC Connection [DEBUG] JDBCTransaction begin [DEBUG] JDBCTransaction current autocommit status: false so commit somehow works. A.C. Davor Hrg wrote: you should call ThreadCleanupHub.cleanup() at the each thread you spawn for your self, or tapestry threaded resources will not get cleaned, and youl make a mem leak. tapestry uses ThreadLocal to store threaded services like Session, for example if any part of the code references session(calls a method) while it is executed from your thread new session for that thread will be created, and without calling ThreadCleanupHub.cleanup() inside that thread service -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15336338.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
you did'nt say if the entity is saved to db, if you call commit explicitely, you'll see changes in log, but the way the snippet works is you create entity, you save it to session you change entity... after your task is done, ThreadCleanupHub.cleanup() is called HibernateSessionManager is a listener for that and calls commit then. so your changes are writen to the database at the end, not every time you modify something or, am I missing sth ? Davor Hrg On Feb 7, 2008 4:42 PM, Angelo Chen [EMAIL PROTECTED] wrote: Hi Davor, Thanks for your ThreadSource, it works and makes threaded tasks in T5 easier, I have included it in my app. however, in my case, the threaded service has insert and update in the same time: Doc doc = new Doc(); session.save(doc); doc.setTitle(test); in the Hibernate log, it has : insert into doc... but you can't see update and commit. if I add a sessionManager.commit() then I can see: update doc set... [DEBUG] JDBCTransaction committed JDBC Connection [DEBUG] JDBCTransaction begin [DEBUG] JDBCTransaction current autocommit status: false so commit somehow works. A.C. Davor Hrg wrote: you should call ThreadCleanupHub.cleanup() at the each thread you spawn for your self, or tapestry threaded resources will not get cleaned, and youl make a mem leak. tapestry uses ThreadLocal to store threaded services like Session, for example if any part of the code references session(calls a method) while it is executed from your thread new session for that thread will be created, and without calling ThreadCleanupHub.cleanup() inside that thread service -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15336338.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Hibernate and threaded service
Hi Davor, Thanks for your ThreadSource, it works and makes threaded tasks in T5 easier, I have included it in my app. however, in my case, the threaded service has insert and update in the same time: Doc doc = new Doc(); session.save(doc); doc.setTitle(test); in the Hibernate log, it has : insert into doc... but you can't see update and commit. if I add a sessionManager.commit() then I can see: update doc set... [DEBUG] JDBCTransaction committed JDBC Connection [DEBUG] JDBCTransaction begin [DEBUG] JDBCTransaction current autocommit status: false so commit somehow works. A.C. Davor Hrg wrote: you should call ThreadCleanupHub.cleanup() at the each thread you spawn for your self, or tapestry threaded resources will not get cleaned, and youl make a mem leak. tapestry uses ThreadLocal to store threaded services like Session, for example if any part of the code references session(calls a method) while it is executed from your thread new session for that thread will be created, and without calling ThreadCleanupHub.cleanup() inside that thread service -- View this message in context: http://www.nabble.com/T5%3A-Hibernate-and-threaded-service-tp15328171p15336338.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]