Re: T5: Hibernate

2007-09-09 Thread Davor Hrg
if you ever had problems like when you have an
app that is idle over night and mysql disconnects you,
or you restart mysql... then typestry page will fail because hibernate
will hold on to the broken connection...

here's an config that uses a pool that can reconnect and discard
broken connections


http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>



org.gjt.mm.mysql.Driver
jdbc:mysql://localhost/dbname?charset=utf8

org.hibernate.dialect.MySQLDialect
user




org.hibernate.connection.C3P0ConnectionProvider
1
100 
10
0
1
100 




On 9/10/07, Davor Hrg <[EMAIL PROTECTED]> wrote:
>
> 
>  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
> " http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd
> ">
> 
> 
> 
> org.gjt.mm.mysql.Driver
> jdbc:mysql://localhost/dbname?charset=utf8
> 
> org.hibernate.dialect.MySQLDialect
> user
> 
> 
> 
>
> On 9/10/07, Angelo Chen < [EMAIL PROTECTED]> wrote:
> >
> >
> > Hi Marcus,
> >
> > Good point, I removed it. but that error still coming out, must be
> > something
> > wrong with the xml file, care to share your hibernate.cfg.xml here so I
> > can
> > build a new one from an already running one.
> >
> >
> > Marcus Schmidke-2 wrote:
> > >
> > > I cannot really tell what the error is, but I am also a beginner and
> > > also started with an existing Hibernate configuration the same way as
> > > you did, so it will be only a small mistake.
> > >
> > >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12587485
> > 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

2007-09-09 Thread Marcus Schmidke
Angelo,

here is mine, really basic, but it works:

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>






com.mysql.jdbc.Driver


jdbc:mysql://192.168.0.102:3306/marcus

marcus



1



org.hibernate.dialect.MySQL5Dialect



thread



org.hibernate.cache.NoCacheProvider



true



update





Marcus.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 on JDK 1.6 or newer

2007-09-09 Thread Peter Stavrinides

Hi Stephan

Thanks for posted this, you have saved a lot of time for me, 
unfortunately for me though I can't go back to JVM 1.5


Stephan Schwab wrote:

Unfortunately yesterday we had to switch back to JVM 1.5, as the same
symptoms have shown up again. Seems that there is still a problem and JVM
1.6. update 2 is not the solution.
  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Hibernate

2007-09-09 Thread Davor Hrg

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>



org.gjt.mm.mysql.Driver
jdbc:mysql://localhost/dbname?charset=utf8

org.hibernate.dialect.MySQLDialect
user




On 9/10/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
>
>
> Hi Marcus,
>
> Good point, I removed it. but that error still coming out, must be
> something
> wrong with the xml file, care to share your hibernate.cfg.xml here so I
> can
> build a new one from an already running one.
>
>
> Marcus Schmidke-2 wrote:
> >
> > I cannot really tell what the error is, but I am also a beginner and
> > also started with an existing Hibernate configuration the same way as
> > you did, so it will be only a small mistake.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12587485
> 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

2007-09-09 Thread Angelo Chen

Hi Marcus,

Good point, I removed it. but that error still coming out, must be something
wrong with the xml file, care to share your hibernate.cfg.xml here so I can
build a new one from an already running one.


Marcus Schmidke-2 wrote:
> 
> I cannot really tell what the error is, but I am also a beginner and
> also started with an existing Hibernate configuration the same way as
> you did, so it will be only a small mistake.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12587485
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] How to use Services - an example, please

2007-09-09 Thread Davor Hrg
Services are ordinary java classes,

difference is only that some objects you will instantiate
by hand, like StringBuffer or File...

Service is a class for which you let tapestry-ioc to
generate instances. You configure which services
are available in your AppModule and define there
how they are created. If you use bind method
then you supply only the Class and let tapestry fill
in dependancies (through constructor).
If you use buildMyService methods then you require
dependacies by liting them as method parameters
and manualy construct your service.

this is how I can explain it, say if it makes any sense,

Davor Hrg



On 9/10/07, Erik Vullings <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I've read the manual about services, but don't get it: It's like seeing
> the
> puzzle pieces, but not the whole. Can someone explain it to me please,
> especially:
>
>1. How can I use a service to connect to my database? Or should I use
>Hibernate?
>2. How can I use a service to access the file system? In the demos,
>Howard uses a service to access his CD library, and it seems really
> cool,
>but I have no idea how he does it...
>
> More specifically, I had a struts2 MVC webapp which I'm porting to T5. It
> had three layers: JSP, which maps nicely to HTML templates, Controllers,
> which are myTapestry components and pages, and my DAL, which is still
> there.
> So for every serious class that I need to persist, it has a DAO that does
> it
> for me e.g.:
>
> public WhateverDAO() {
> dataSource = new DriverManagerDataSource();
> dataSource.setDriverClassName(Globals.dbDriver);
> dataSource.setUrl(Globals.dbURL);
> dataSource.setUsername(Globals.dbUsername);
> dataSource.setPassword(Globals.dbPassword);
> ...
> }
> public List retrieve(long poId) throws SQLException {
> JdbcTemplate jt = new JdbcTemplate(dataSource);
> ...
> }
>
> This does not seem to be the Tapestry way, but can someone show me the
> true
> path :-) A service seems to be the answer... or Hibernate, but I'm not
> sure
> whether that will save me a lot of time.
>
> Thanks,
> Erik
>


Re: T5: Hibernate

2007-09-09 Thread Marcus Schmidke
I cannot really tell what the error is, but I am also a beginner and
also started with an existing Hibernate configuration the same way as
you did, so it will be only a small mistake.

One thing I think is important is that Tapestry Hibernate
automatically configures all @Entity classes in the "entities"
package.

So I think you have to remove the "mapping" entry in the
hibernate-config. Either an entity is configured by hibernate config
or programatically (by tapestry in this case), but not both.

Marcus.

2007/9/10, Angelo Chen <[EMAIL PROTECTED]>:
>
> Hi Davor,
>
> I read the doc and do the following:
>
> 1. put Fruit.java under entities package
> 2. put hibernate.cfg.xml under resources
> 3. in the Start.java, I add:
>  @Inject private Session _session;
>
> String onAction() {
> Fruit f = new Fruit();
> f.setName("Orange");
> f.setPrice(10);
> _session.save(f);
> _session.close();
>   return null; }
>
> I got following error:
>
> The content of element type "session-factory" must match
> "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
>
> here are the related files:
>
> Fruit.java
> package org.bfe.hbm.entities;
> import javax.persistence.*;
> @Entity
> @Table(name="Fruit")
> public class Fruit {
> @Id @GeneratedValue
> private long id;
> private String name;
> private int price;
> public long getId() {
> return id;}
> public void setId(long id) {
> this.id = id;}
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;}
> public int getPrice() {
> return price;}
> public void setPrice(int price) {
> this.price = price;}
> }
>
> hibernate.cfg.xml:(note: this is taken from a working app, except changed
> mapping class from xml to anotated)
>
> 
>  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>
>
> 
>
> 
>
> 
> 
>
> 
>  name="connection.driver_class">com.mysql.jdbc.Driver
>  name="connection.url">jdbc:mysql://localhost/animal
> root
> 
>
> 
> 1
>
> 
>   name="dialect">org.hibernate.dialect.MySQLDialect
>
> 
> thread
>
> 
>  name="cache.provider_class">org.hibernate.cache.NoCacheProvider
>
> 
> true
>
> 
>create -
>
> 
>
>
>
> 
>
> 
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Hibernate

2007-09-09 Thread Davor Hrg
you must generate hibernate.cfg.xml
have your entities in entities package
add this to your AppModule

public static void
contributeValueEncoderSource(MappedConfiguration,
ValueEncoderFactory> configuration,
Session session
) {
   configuration.add(ObjektMitSeqID.class, new
HibernateValueEncoderFactory(session));
}

that is for getting the session


here is my hibernate.cfg.xml
tapestry will add your entities to the session factory if they are in
entities package


http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>



org.gjt.mm.mysql.Driver
jdbc:mysql://localhost/dbname?charset=utf8&autoReconnect=true

org.hibernate.dialect.MySQLDialect
uname




org.hibernate.connection.C3P0ConnectionProvider
1
100 
10
0
1
100 





On 9/10/07, Marcus Schmidke <[EMAIL PROTECTED]> wrote:
>
> Yes ... I've read ... parts of it more than once ... but
> unfortunately, I do not seem to be clever enough.
>
> I want to write a value encoder which maps Hibernate Entities to their
> IDs and vice versa.
>
> I've written
> - a HibernateValueEncoder
> - a HibernateValueEncoderFactory
> - an AppModule containing the following:
>
> public static void
> contributeValueEncoderSource(MappedConfiguration,
> ValueEncoderFactory> configuration) {
> configuration.add(ObjektMitSeqID.class, new
> HibernateValueEncoderFactory());
> }
>
> (where ObjektMitSeqID is the base class of all of my Hibernate Entities).
>
> This all works fine, no problem, but only as long as I use my own
> HibernateUtil to create a Session. But I would prefer using tapestry
> to create the Hibernate Session.
>
> Since I don't create a service on my own, but only contribute
> configuration to an existing service, I have absolutely no plan how or
> where to inject the Hibernate Session.
>
> Perhaps I'm a little bit confused. I don't know. Do you have another hint?
>
>
> Marcus.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: T5: Hibernate

2007-09-09 Thread Ulrich Stärk
The Hibernate  configuration element doesn't expect a package with annotated 
classes as one might assume but expects an annotated package with package-level annotations like 
@GenericGenerator. So you must explicitly add every annotated class to your Hibernate configuration 
with a  element (or do it programmatically).
You might also want to have a look at the Hibernate Entitymanager which apart from being a JPA 
implementation and thus making your OR mapper exchangeable also gives you the convenience of 
searching for annotated classes by itself.


Cheers,

Uli

Lindsay Steele schrieb:
Just by co-incidence,  I am trying to get Hibernate working but I am 
getting the following error in the logs.


08:10:04.531 WARN!! [SocketListener0-1] 
org.hibernate.cfg.AnnotationBinder.bindPackage(AnnotationBinder.java:217) 
 >90> Package not found or wo package-info.java: 
ozpoultry.breeders.entities


The package definitely exists.  It is a base package at the level of 
pages, components etc etc.  There is also an entity class in the package.

Is there something I am missing ?

Davor Hrg wrote:

not much at the moment,
but it's simple to use,
factories are created
http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html

you just call
@Inject private Session _session;

or in the method
Especialy if you have DAO's that have Session in constructor
than you can configure them efortlessly via AppModule.bind

I havent got much time to write you more ...
but try it out a bit, it works like a charm


Davor Hrg

On 9/9/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
 

Hi,

I searched the list to find a simple tutorial for Tapestry-hibernate, 
but

couldn't find any, some quite simple, but source code not complete. any
simple code there? anyway, I believe Hibernate can be used directly
without
Tapestry-hibernate module, my question now is, what are the advantages
using
Tapestry-hibernate over using the Hibernate directly? Thanks for 
sharing,

A.C.
--
View this message in context:
http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12579774
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

2007-09-09 Thread Angelo Chen

Hi Jun,

I believe it has something to do with that, but which part? I use it in a
java application, it works, that's what is puzzling me.

A.C.


Jun Tsai-2 wrote:
> 
> see your hibernate.cfg.xml file.
> 
> Jun Tsai
> 
> 2007/9/10, Angelo Chen <[EMAIL PROTECTED]>:
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12586649
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

2007-09-09 Thread Jun Tsai
see your hibernate.cfg.xml file.

Jun Tsai

2007/9/10, Angelo Chen <[EMAIL PROTECTED]>:
>
>
> Hi Davor,
>
> I read the doc and do the following:
>
> 1. put Fruit.java under entities package
> 2. put hibernate.cfg.xml under resources
> 3. in the Start.java, I add:
> @Inject private Session _session;
>
> String onAction() {
> Fruit f = new Fruit();
> f.setName("Orange");
> f.setPrice(10);
> _session.save(f);
> _session.close();
>   return null; }
>
> I got following error:
>
> The content of element type "session-factory" must match
> "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
>
> here are the related files:
>
> Fruit.java
> package org.bfe.hbm.entities;
> import javax.persistence.*;
> @Entity
> @Table(name="Fruit")
> public class Fruit {
> @Id @GeneratedValue
> private long id;
> private String name;
> private int price;
> public long getId() {
> return id;}
> public void setId(long id) {
> this.id = id;}
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;}
> public int getPrice() {
> return price;}
> public void setPrice(int price) {
> this.price = price;}
> }
>
> hibernate.cfg.xml:(note: this is taken from a working app, except changed
> mapping class from xml to anotated)
>
> 
>  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd
> ">
>
> 
>
> 
>
> 
> 
>
> 
>  name="connection.driver_class">com.mysql.jdbc.Driver
>  name="connection.url">jdbc:mysql://localhost/animal
> root
> 
>
> 
> 1
>
> 
>   name="dialect">org.hibernate.dialect.MySQLDialect
>
> 
> thread
>
> 
>  name="cache.provider_class">org.hibernate.cache.NoCacheProvider
>
> 
> true
>
> 
>create -
>
> 
>
>
>
> 
>
> 
>
>
> Davor Hrg wrote:
> >
> > not much at the moment,
> > but it's simple to use,
> > factories are created
> > http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html
> >
> > you just call
> > @Inject private Session _session;
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12586367
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
regards,
Jun Tsai


Re: T5: Hibernate

2007-09-09 Thread Angelo Chen

Hi Davor,

I read the doc and do the following:

1. put Fruit.java under entities package
2. put hibernate.cfg.xml under resources
3. in the Start.java, I add:
 @Inject private Session _session;

String onAction() {
Fruit f = new Fruit();
f.setName("Orange");
f.setPrice(10);
_session.save(f);
_session.close();
  return null; }

I got following error:

The content of element type "session-factory" must match
"(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".

here are the related files:

Fruit.java
package org.bfe.hbm.entities;
import javax.persistence.*;
@Entity
@Table(name="Fruit")
public class Fruit {
@Id @GeneratedValue
private long id;
private String name;
private int price;
public long getId() {
return id;}
public void setId(long id) {
this.id = id;}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;}
public int getPrice() {
return price;}
public void setPrice(int price) {
this.price = price;}
}

hibernate.cfg.xml:(note: this is taken from a working app, except changed
mapping class from xml to anotated)


http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>









com.mysql.jdbc.Driver
jdbc:mysql://localhost/animal
root



1


 org.hibernate.dialect.MySQLDialect


thread


org.hibernate.cache.NoCacheProvider


true


   create -










Davor Hrg wrote:
> 
> not much at the moment,
> but it's simple to use,
> factories are created
> http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html
> 
> you just call
> @Inject private Session _session;
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12586367
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] How to use Services - an example, please

2007-09-09 Thread smithfox


http://code.google.com/p/lichen-forum/


Erik Vullings-2 wrote:
> 
> Hi,
> 
> I've read the manual about services, but don't get it: It's like seeing
> the
> puzzle pieces, but not the whole. Can someone explain it to me please,
> especially:
> 
>1. How can I use a service to connect to my database? Or should I use
>Hibernate?
>2. How can I use a service to access the file system? In the demos,
>Howard uses a service to access his CD library, and it seems really
> cool,
>but I have no idea how he does it...
> 
> More specifically, I had a struts2 MVC webapp which I'm porting to T5. It
> had three layers: JSP, which maps nicely to HTML templates, Controllers,
> which are myTapestry components and pages, and my DAL, which is still
> there.
> So for every serious class that I need to persist, it has a DAO that does
> it
> for me e.g.:
> 
> public WhateverDAO() {
> dataSource = new DriverManagerDataSource();
> dataSource.setDriverClassName(Globals.dbDriver);
> dataSource.setUrl(Globals.dbURL);
> dataSource.setUsername(Globals.dbUsername);
> dataSource.setPassword(Globals.dbPassword);
> ...
> }
> public List retrieve(long poId) throws SQLException {
> JdbcTemplate jt = new JdbcTemplate(dataSource);
> ...
> }
> 
> This does not seem to be the Tapestry way, but can someone show me the
> true
> path :-) A service seems to be the answer... or Hibernate, but I'm not
> sure
> whether that will save me a lot of time.
> 
> Thanks,
> Erik
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-T5--How-to-use-Services---an-example%2C-please-tf4411200.html#a12584957
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

2007-09-09 Thread Angelo Chen

Hi Davor,

Thanks, as a newbie, i can't really understand it fully, here is what I got
so far:

1) put that tapestry-hibernate.jar in the lib.
2) put all annotated entities in the entities direcotory
3) in your main source:
@inject  private Session _session;

   then? what's the Session of this? Hibernate's getSessionFactory?

Thanks,
 


Davor Hrg wrote:
> 
> not much at the moment,
> but it's simple to use,
> factories are created
> http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html
> 
> you just call
> @Inject private Session _session;
> 
> or in the method
> Especialy if you have DAO's that have Session in constructor
> than you can configure them efortlessly via AppModule.bind
> 
> I havent got much time to write you more ...
> but try it out a bit, it works like a charm
> 
> 
> Davor Hrg
> 
> On 9/9/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hi,
>>
>> I searched the list to find a simple tutorial for Tapestry-hibernate, but
>> couldn't find any, some quite simple, but source code not complete. any
>> simple code there? anyway, I believe Hibernate can be used directly
>> without
>> Tapestry-hibernate module, my question now is, what are the advantages
>> using
>> Tapestry-hibernate over using the Hibernate directly? Thanks for sharing,
>> A.C.
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12579774
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> -
>> 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-tf4409684.html#a12584735
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

2007-09-09 Thread Lindsay Steele
Just by co-incidence,  I am trying to get Hibernate working but I am 
getting the following error in the logs.


08:10:04.531 WARN!! [SocketListener0-1] 
org.hibernate.cfg.AnnotationBinder.bindPackage(AnnotationBinder.java:217) 
>90> Package not found or wo package-info.java: ozpoultry.breeders.entities


The package definitely exists.  It is a base package at the level of 
pages, components etc etc.  There is also an entity class in the package. 


Is there something I am missing ?

Davor Hrg wrote:

not much at the moment,
but it's simple to use,
factories are created
http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html

you just call
@Inject private Session _session;

or in the method
Especialy if you have DAO's that have Session in constructor
than you can configure them efortlessly via AppModule.bind

I havent got much time to write you more ...
but try it out a bit, it works like a charm


Davor Hrg

On 9/9/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
  

Hi,

I searched the list to find a simple tutorial for Tapestry-hibernate, but
couldn't find any, some quite simple, but source code not complete. any
simple code there? anyway, I believe Hibernate can be used directly
without
Tapestry-hibernate module, my question now is, what are the advantages
using
Tapestry-hibernate over using the Hibernate directly? Thanks for sharing,
A.C.
--
View this message in context:
http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12579774
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

2007-09-09 Thread Marcus Schmidke
Still not in bed .. was too curious about that session thing.

Adding this parameter indeed works - I get some kind of session object
in the contribute method. But what session is this? Is it a session
which is created at this moment (and is already closed when I really
need it) or is it some kind of proxy which always points to the
session which is active in the moment I need it?

Marcus.

2007/9/10, Marcus Schmidke <[EMAIL PROTECTED]>:
> Ok ...,
>
> I took a shower which made things much much clearer.
>
> I think I should build and register a BusinessService (just like a
> stateless session bean) which encapsulates the Hibernate things. This
> Service can have the Hibernate Session injected on some different ways
> (just like explained in the document you mentioned), and my value
> encoder can make use of this service (I tried to add the service as
> parameter to the contributeValueEncoderSource method, and damn! it
> worked).
>
> Great, all this seems to work now. Was not too complicated, perhaps
> only too late for me. Time to go to bed.
>
> Have a good night!
>
> Marcus.
>
> PS. I'm just thinking about what had happened if I had added a
> Hibernate Session parameter to contributeValueEncoderSource's
> parameter list? Perhaps this would have worked either?
>
>
> 2007/9/10, Marcus Schmidke <[EMAIL PROTECTED]>:
> > Yes ... I've read ... parts of it more than once ... but
> > unfortunately, I do not seem to be clever enough.
> >
> > I want to write a value encoder which maps Hibernate Entities to their
> > IDs and vice versa.
> >
> > I've written
> > - a HibernateValueEncoder
> > - a HibernateValueEncoderFactory
> > - an AppModule containing the following:
> >
> > public static void
> > contributeValueEncoderSource(MappedConfiguration,
> > ValueEncoderFactory> configuration) {
> > configuration.add(ObjektMitSeqID.class, new 
> > HibernateValueEncoderFactory());
> > }
> >
> > (where ObjektMitSeqID is the base class of all of my Hibernate Entities).
> >
> > This all works fine, no problem, but only as long as I use my own
> > HibernateUtil to create a Session. But I would prefer using tapestry
> > to create the Hibernate Session.
> >
> > Since I don't create a service on my own, but only contribute
> > configuration to an existing service, I have absolutely no plan how or
> > where to inject the Hibernate Session.
> >
> > Perhaps I'm a little bit confused. I don't know. Do you have another hint?
> >
> >
> > Marcus.
> >
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Hibernate

2007-09-09 Thread Marcus Schmidke
Ok ...,

I took a shower which made things much much clearer.

I think I should build and register a BusinessService (just like a
stateless session bean) which encapsulates the Hibernate things. This
Service can have the Hibernate Session injected on some different ways
(just like explained in the document you mentioned), and my value
encoder can make use of this service (I tried to add the service as
parameter to the contributeValueEncoderSource method, and damn! it
worked).

Great, all this seems to work now. Was not too complicated, perhaps
only too late for me. Time to go to bed.

Have a good night!

Marcus.

PS. I'm just thinking about what had happened if I had added a
Hibernate Session parameter to contributeValueEncoderSource's
parameter list? Perhaps this would have worked either?


2007/9/10, Marcus Schmidke <[EMAIL PROTECTED]>:
> Yes ... I've read ... parts of it more than once ... but
> unfortunately, I do not seem to be clever enough.
>
> I want to write a value encoder which maps Hibernate Entities to their
> IDs and vice versa.
>
> I've written
> - a HibernateValueEncoder
> - a HibernateValueEncoderFactory
> - an AppModule containing the following:
>
> public static void
> contributeValueEncoderSource(MappedConfiguration,
> ValueEncoderFactory> configuration) {
> configuration.add(ObjektMitSeqID.class, new 
> HibernateValueEncoderFactory());
> }
>
> (where ObjektMitSeqID is the base class of all of my Hibernate Entities).
>
> This all works fine, no problem, but only as long as I use my own
> HibernateUtil to create a Session. But I would prefer using tapestry
> to create the Hibernate Session.
>
> Since I don't create a service on my own, but only contribute
> configuration to an existing service, I have absolutely no plan how or
> where to inject the Hibernate Session.
>
> Perhaps I'm a little bit confused. I don't know. Do you have another hint?
>
>
> Marcus.
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[T5] How to use Services - an example, please

2007-09-09 Thread Erik Vullings
Hi,

I've read the manual about services, but don't get it: It's like seeing the
puzzle pieces, but not the whole. Can someone explain it to me please,
especially:

   1. How can I use a service to connect to my database? Or should I use
   Hibernate?
   2. How can I use a service to access the file system? In the demos,
   Howard uses a service to access his CD library, and it seems really cool,
   but I have no idea how he does it...

More specifically, I had a struts2 MVC webapp which I'm porting to T5. It
had three layers: JSP, which maps nicely to HTML templates, Controllers,
which are myTapestry components and pages, and my DAL, which is still there.
So for every serious class that I need to persist, it has a DAO that does it
for me e.g.:

public WhateverDAO() {
dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(Globals.dbDriver);
dataSource.setUrl(Globals.dbURL);
dataSource.setUsername(Globals.dbUsername);
dataSource.setPassword(Globals.dbPassword);
...
}
public List retrieve(long poId) throws SQLException {
JdbcTemplate jt = new JdbcTemplate(dataSource);
...
}

This does not seem to be the Tapestry way, but can someone show me the true
path :-) A service seems to be the answer... or Hibernate, but I'm not sure
whether that will save me a lot of time.

Thanks,
Erik


Re: T5: Hibernate

2007-09-09 Thread Marcus Schmidke
Yes ... I've read ... parts of it more than once ... but
unfortunately, I do not seem to be clever enough.

I want to write a value encoder which maps Hibernate Entities to their
IDs and vice versa.

I've written
- a HibernateValueEncoder
- a HibernateValueEncoderFactory
- an AppModule containing the following:

public static void
contributeValueEncoderSource(MappedConfiguration,
ValueEncoderFactory> configuration) {
configuration.add(ObjektMitSeqID.class, new 
HibernateValueEncoderFactory());
}

(where ObjektMitSeqID is the base class of all of my Hibernate Entities).

This all works fine, no problem, but only as long as I use my own
HibernateUtil to create a Session. But I would prefer using tapestry
to create the Hibernate Session.

Since I don't create a service on my own, but only contribute
configuration to an existing service, I have absolutely no plan how or
where to inject the Hibernate Session.

Perhaps I'm a little bit confused. I don't know. Do you have another hint?


Marcus.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: Hibernate

2007-09-09 Thread Davor Hrg
ok,
pages you know now ...

other time you create your classes is inside your module AppModule
Tapestry-ioc subsystem is in charge here
http://tapestry.apache.org/tapestry5/tapestry-ioc/

read this page to get more information on dependecy injection in general
you will need this stuff often
http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html

since you mention ValueEncoder I belive you are using select Component
try this little tutorial I wrote recently
http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects


generaly, try this page for other tutorials
http://wiki.apache.org/tapestry/Tapestry5HowTos

Davor Hrg


On 9/9/07, Marcus Schmidke <[EMAIL PROTECTED]> wrote:
>
> I accidentally found this thread and also tried to get Hibernate
> integration running.
>
> Basically, it runs, but I still know too few about Tapestry basics.
>
> @Inject works fine for page components, but how can I make it work in
> other classes?
>
> Concretely, how can I inject a hibernate session into my ValueEncoder?
>
> Marcus.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: T5: Hibernate

2007-09-09 Thread Marcus Schmidke
I accidentally found this thread and also tried to get Hibernate
integration running.

Basically, it runs, but I still know too few about Tapestry basics.

@Inject works fine for page components, but how can I make it work in
other classes?

Concretely, how can I inject a hibernate session into my ValueEncoder?

Marcus.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 on JDK 1.6 or newer

2007-09-09 Thread Stephan Schwab

Unfortunately yesterday we had to switch back to JVM 1.5, as the same
symptoms have shown up again. Seems that there is still a problem and JVM
1.6. update 2 is not the solution.
-- 
View this message in context: 
http://www.nabble.com/T5-on-JDK-1.6-or-newer-tf4324659.html#a12582298
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

2007-09-09 Thread Davor Hrg
not much at the moment,
but it's simple to use,
factories are created
http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html

you just call
@Inject private Session _session;

or in the method
Especialy if you have DAO's that have Session in constructor
than you can configure them efortlessly via AppModule.bind

I havent got much time to write you more ...
but try it out a bit, it works like a charm


Davor Hrg

On 9/9/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I searched the list to find a simple tutorial for Tapestry-hibernate, but
> couldn't find any, some quite simple, but source code not complete. any
> simple code there? anyway, I believe Hibernate can be used directly
> without
> Tapestry-hibernate module, my question now is, what are the advantages
> using
> Tapestry-hibernate over using the Hibernate directly? Thanks for sharing,
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12579774
> 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

2007-09-09 Thread Angelo Chen

Hi,

I searched the list to find a simple tutorial for Tapestry-hibernate, but
couldn't find any, some quite simple, but source code not complete. any
simple code there? anyway, I believe Hibernate can be used directly without
Tapestry-hibernate module, my question now is, what are the advantages using
Tapestry-hibernate over using the Hibernate directly? Thanks for sharing,
A.C.
-- 
View this message in context: 
http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12579774
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]