You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Duro <de...@yahoo.com> on 2011/03/10 13:12:08 UTC
entity manager in webapp
Hi guys, is this an option to store the JPA entity manager for a wicket
webapp:
public class DBUtil {
private static EntityManagerFactory entityManagerFactory = Persistence
.createEntityManagerFactory("db");
private static ThreadLocal<EntityManager> emHolder = new
ThreadLocal<EntityManager>() {
protected EntityManager initialValue() {
return entityManagerFactory.createEntityManager();
};
};
public static User getUser(String userName) {
return emHolder.get().find(User.class, userName);
}
..................
If not, thanks for possible better solutions, Juraj
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: entity manager in webapp
Posted by Cristiano GaviĆ£o <cv...@gmail.com>.
Well, warp-persist became Guice-Persist... and it is part of 3.0:
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-persist</artifactId>
<version>3.0-rc3</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0-rc3</version>
</dependency>
cheers
Cristiano
On 10/03/11 12:01, Witold Czaplewski wrote:
> IMO warp-persist is dead and Guice 3.0 should be final soon (rc3 is out now):
> http://code.google.com/p/google-guice/downloads/list
>
>
> Witold
>
> Am Thu, 10 Mar 2011 15:31:19 +0100
> schrieb Bas Gooren<ba...@iswd.nl>:
>
>> Which is basically warp-persist, but integrated into guice. But as far
>> as I know, it will be only be integrated as of guice 3.0;
>>
>> Bas
>>
>> Op 10-3-2011 15:29, nino martinez wael schreef:
>>> I'd go for guice persist if thats an option..
>>>
>>> 2011/3/10 Bas Gooren<ba...@iswd.nl>
>>>
>>>> Have a look at databinder or warp-persist for a better implementation.
>>>>
>>>> Should you go with your own implementation, do not forget to clear the
>>>> ThreadLocal at the end of the request to prevent:
>>>> a) leaking
>>>> b) re-using an EntityManager from a previous request (most if not all
>>>> application servers use a thread pool)
>>>>
>>>> Bas
>>>>
>>>> Op 10-3-2011 13:12, Duro schreef:
>>>>
>>>> Hi guys, is this an option to store the JPA entity manager for a wicket
>>>>> webapp:
>>>>> public class DBUtil {
>>>>> private static EntityManagerFactory entityManagerFactory = Persistence
>>>>> .createEntityManagerFactory("db");
>>>>> private static ThreadLocal<EntityManager> emHolder = new
>>>>> ThreadLocal<EntityManager>() {
>>>>> protected EntityManager initialValue() {
>>>>> return entityManagerFactory.createEntityManager();
>>>>> };
>>>>> };
>>>>>
>>>>> public static User getUser(String userName) {
>>>>> return emHolder.get().find(User.class, userName);
>>>>> }
>>>>>
>>>>> ..................
>>>>>
>>>>> If not, thanks for possible better solutions, Juraj
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: entity manager in webapp
Posted by Witold Czaplewski <wi...@cts-media.eu>.
IMO warp-persist is dead and Guice 3.0 should be final soon (rc3 is out now):
http://code.google.com/p/google-guice/downloads/list
Witold
Am Thu, 10 Mar 2011 15:31:19 +0100
schrieb Bas Gooren <ba...@iswd.nl>:
> Which is basically warp-persist, but integrated into guice. But as far
> as I know, it will be only be integrated as of guice 3.0;
>
> Bas
>
> Op 10-3-2011 15:29, nino martinez wael schreef:
> > I'd go for guice persist if thats an option..
> >
> > 2011/3/10 Bas Gooren<ba...@iswd.nl>
> >
> >> Have a look at databinder or warp-persist for a better implementation.
> >>
> >> Should you go with your own implementation, do not forget to clear the
> >> ThreadLocal at the end of the request to prevent:
> >> a) leaking
> >> b) re-using an EntityManager from a previous request (most if not all
> >> application servers use a thread pool)
> >>
> >> Bas
> >>
> >> Op 10-3-2011 13:12, Duro schreef:
> >>
> >> Hi guys, is this an option to store the JPA entity manager for a wicket
> >>> webapp:
> >>> public class DBUtil {
> >>> private static EntityManagerFactory entityManagerFactory = Persistence
> >>> .createEntityManagerFactory("db");
> >>> private static ThreadLocal<EntityManager> emHolder = new
> >>> ThreadLocal<EntityManager>() {
> >>> protected EntityManager initialValue() {
> >>> return entityManagerFactory.createEntityManager();
> >>> };
> >>> };
> >>>
> >>> public static User getUser(String userName) {
> >>> return emHolder.get().find(User.class, userName);
> >>> }
> >>>
> >>> ..................
> >>>
> >>> If not, thanks for possible better solutions, Juraj
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: entity manager in webapp
Posted by Bas Gooren <ba...@iswd.nl>.
Which is basically warp-persist, but integrated into guice. But as far
as I know, it will be only be integrated as of guice 3.0;
Bas
Op 10-3-2011 15:29, nino martinez wael schreef:
> I'd go for guice persist if thats an option..
>
> 2011/3/10 Bas Gooren<ba...@iswd.nl>
>
>> Have a look at databinder or warp-persist for a better implementation.
>>
>> Should you go with your own implementation, do not forget to clear the
>> ThreadLocal at the end of the request to prevent:
>> a) leaking
>> b) re-using an EntityManager from a previous request (most if not all
>> application servers use a thread pool)
>>
>> Bas
>>
>> Op 10-3-2011 13:12, Duro schreef:
>>
>> Hi guys, is this an option to store the JPA entity manager for a wicket
>>> webapp:
>>> public class DBUtil {
>>> private static EntityManagerFactory entityManagerFactory = Persistence
>>> .createEntityManagerFactory("db");
>>> private static ThreadLocal<EntityManager> emHolder = new
>>> ThreadLocal<EntityManager>() {
>>> protected EntityManager initialValue() {
>>> return entityManagerFactory.createEntityManager();
>>> };
>>> };
>>>
>>> public static User getUser(String userName) {
>>> return emHolder.get().find(User.class, userName);
>>> }
>>>
>>> ..................
>>>
>>> If not, thanks for possible better solutions, Juraj
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
Re: entity manager in webapp
Posted by nino martinez wael <ni...@gmail.com>.
I'd go for guice persist if thats an option..
2011/3/10 Bas Gooren <ba...@iswd.nl>
> Have a look at databinder or warp-persist for a better implementation.
>
> Should you go with your own implementation, do not forget to clear the
> ThreadLocal at the end of the request to prevent:
> a) leaking
> b) re-using an EntityManager from a previous request (most if not all
> application servers use a thread pool)
>
> Bas
>
> Op 10-3-2011 13:12, Duro schreef:
>
> Hi guys, is this an option to store the JPA entity manager for a wicket
>> webapp:
>> public class DBUtil {
>> private static EntityManagerFactory entityManagerFactory = Persistence
>> .createEntityManagerFactory("db");
>> private static ThreadLocal<EntityManager> emHolder = new
>> ThreadLocal<EntityManager>() {
>> protected EntityManager initialValue() {
>> return entityManagerFactory.createEntityManager();
>> };
>> };
>>
>> public static User getUser(String userName) {
>> return emHolder.get().find(User.class, userName);
>> }
>>
>> ..................
>>
>> If not, thanks for possible better solutions, Juraj
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
Re: entity manager in webapp
Posted by Bas Gooren <ba...@iswd.nl>.
Have a look at databinder or warp-persist for a better implementation.
Should you go with your own implementation, do not forget to clear the
ThreadLocal at the end of the request to prevent:
a) leaking
b) re-using an EntityManager from a previous request (most if not all
application servers use a thread pool)
Bas
Op 10-3-2011 13:12, Duro schreef:
> Hi guys, is this an option to store the JPA entity manager for a
> wicket webapp:
> public class DBUtil {
> private static EntityManagerFactory entityManagerFactory =
> Persistence
> .createEntityManagerFactory("db");
> private static ThreadLocal<EntityManager> emHolder = new
> ThreadLocal<EntityManager>() {
> protected EntityManager initialValue() {
> return entityManagerFactory.createEntityManager();
> };
> };
>
> public static User getUser(String userName) {
> return emHolder.get().find(User.class, userName);
> }
>
> ..................
>
> If not, thanks for possible better solutions, Juraj
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>