You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Wolfgang Wagner <ww...@csc.com> on 2008/01/06 20:37:46 UTC
orchestra with plain hibernate
Hi
I would like to use orchestra with hibernate in a JSF project. As far as I
could find out orchestra is fairly strong coupled to JPA (at least the
example programs). As we do not yet have any experiances inJPA, but have
some experiances in Hibernate and Hibernate-Spring integration I would
prefer to use plain Hibernate.
Here my questions,
Is there any reason not to use plain Hibernate ?
Does anyone have some sample configuration and DAOs to illustrate how this
could work ?
Re: orchestra with plain hibernate
Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> WOW that was quick.
> If you also have an exitsing ApplicationContext.xml file and an
> example DAO, that would help a lot.
> I specially dont know what object will be injected into the DAO
> instead of the EntityManager from the regular examples.
Ok, I took the time to setup the long awaited orchestra goodies project [1].
There you'll find a myfaces-orchestra-hibernate which consists of two
modules.
* myfaces-orchestra-hibernate-core
* myfaces-orchestra-hibernate-examples
The core currently just holds the HibernatePersistencesContextFactory.
The examples module holds a VERY simple (and probaby wrong -
quick-and-dirty - from the top of my head hacked) test app.
Just checkout the tree as described here [2] and do a "mvn install",
afterwards cd into the examples module and call "mvn jetty:run". This
will startup a local servlet container waiting on port 9090 for your
browser to connect.
The simple example shows that the entities are the same between the
requests which indicates an ongoing conversation and allows you to
easily change their data. The Button "new Conversation" invalidates the
current conversation which will start a new one immediately - resulting
in new instances of the entity objects.
As you might see, the example use a simple DAO extending the
HibernateDaoSupport. Wheter you use this or any other Spring way to deal
with Hibernate is upt to you, also if you use the @Transactional
annotation for transaction demarcation or not is up to you. Any standard
Spring way should do the trick.
Orchestra transparently sits in between and ensures to provide the same
(Hibernate)Session for the ongoing conversation.
I hope everything is setup correctly, else come up again.
Ciao,
Mario
[1] http://code.google.com/p/myfaces-orchestra-goodies/
[2] http://code.google.com/p/myfaces-orchestra-goodies/source
Re: orchestra with plain hibernate
Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> Is there any reason not to use plain Hibernate ?
>
No. It should work by design. In fact, we use plain Hibernate 3 +
Hiberanate-Annotations which is VERY close to JPA, well, but not exactly.
> Does anyone have some sample configuration and DAOs to illustrate how this
> could work ?
>
One of my long-term todos, sorry for still not illustrate how it should
work.
Here [1] you'll find a PersistenceContextFactory which is able to deal
with Hibernate's SessionFactory. The rest is Orchestra standard and you
should be able to work with your entities as previously - using Spring
in your case.
If you need further help, ask again and probably I'll take the time to
setup an example.
Good luck!
Ciao,
Mario
[1] http://l3x.net/imwiki/Wiki.jsp?page=MoreOrchestra