Shared entities - Container-managed persitence

View: New views
3 Messages — Rating Filter:   Alert me  

Shared entities - Container-managed persitence

by Allan Juul-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi

[first post here]

is the following scenario possible ?

In my GF webContainer i have two web applications:

   /webappWriter

   /webappReader


these two web apps should access data from the same datasource (mysql
db) and therefore (hopefully) share the same entity classes.

so these entity classes will be in some "shared" og "common" namespaced
library.


if I create separate identical Entityclasses it seems to work ok, but if
i factor these out to my common library i get a

****
java.lang.IllegalArgumentException: Object:
my.name.space.common.Item[id=1244876498959]
is not a known entity type
****


i imagine i have a persitence.xml issue - because the "common" library
need its own persitence.xml (at least in netbeans) and so does the
respective webapps. so which one wins?


anyway, any pointers much appreciated

./allan

Re: Shared entities - Container-managed persitence

by Wouter van Reeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Allan,


I'd say you need to create one EJB module and two WEB modules in NetBeans. The
EJB module would need a persistence.xml and the two WEB modules will need to
lookup local session beans from the EJB module to fetch their data. In that
way, only one module is responsible for the database connection (i.e. the EJB
module) and both WEB modules share the same Entities and Entity cache.

Is that what you're after?


HTH, Wouter van Reeven

On Sat, Jun 13, 2009 at 09:05:41AM +0200, Allan Juul wrote:

> hi
>
> [first post here]
>
> is the following scenario possible ?
>
> In my GF webContainer i have two web applications:
>
>   /webappWriter
>
>   /webappReader
>
>
> these two web apps should access data from the same datasource (mysql
> db) and therefore (hopefully) share the same entity classes.
>
> so these entity classes will be in some "shared" og "common" namespaced
> library.
>
>
> if I create separate identical Entityclasses it seems to work ok, but if
> i factor these out to my common library i get a
>
> ****
> java.lang.IllegalArgumentException: Object:
> my.name.space.common.Item[id=1244876498959]
> is not a known entity type
> ****
>
>
> i imagine i have a persitence.xml issue - because the "common" library
> need its own persitence.xml (at least in netbeans) and so does the
> respective webapps. so which one wins?
>
>
> anyway, any pointers much appreciated
>
> ./allan

--
Blackholes are where God is dividing by zero.
[Unknown Source]

Skype: wvreeven
Facebook: wvreeven
Twitter: wvreeven

Re: Shared entities - Container-managed persitence

by allan juul-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi Wouter,

sounds very much like what i need. i'll take a look into it.
thanks a lot!
./allan


Wouter van Reeven wrote:

> Hi Allan,
>
>
> I'd say you need to create one EJB module and two WEB modules in NetBeans. The
> EJB module would need a persistence.xml and the two WEB modules will need to
> lookup local session beans from the EJB module to fetch their data. In that
> way, only one module is responsible for the database connection (i.e. the EJB
> module) and both WEB modules share the same Entities and Entity cache.
>
> Is that what you're after?
>
>
> HTH, Wouter van Reeven
>
> On Sat, Jun 13, 2009 at 09:05:41AM +0200, Allan Juul wrote:
>> hi
>>
>> [first post here]
>>
>> is the following scenario possible ?
>>
>> In my GF webContainer i have two web applications:
>>
>>   /webappWriter
>>
>>   /webappReader
>>
>>
>> these two web apps should access data from the same datasource (mysql
>> db) and therefore (hopefully) share the same entity classes.
>>
>> so these entity classes will be in some "shared" og "common" namespaced
>> library.
>>
>>
>> if I create separate identical Entityclasses it seems to work ok, but if
>> i factor these out to my common library i get a
>>
>> ****
>> java.lang.IllegalArgumentException: Object:
>> my.name.space.common.Item[id=1244876498959]
>> is not a known entity type
>> ****
>>
>>
>> i imagine i have a persitence.xml issue - because the "common" library
>> need its own persitence.xml (at least in netbeans) and so does the
>> respective webapps. so which one wins?
>>
>>
>> anyway, any pointers much appreciated
>>
>> ./allan
>