Do you need the lazy loading functionality that proxies provide? It seems to me that if
you have an EJB call that's providing the objects loaded from hibernate, that's
probably not the case. (i.e. once the objects are loaded and returned by the EJB method,
the hibernate session may no longer be available, so lazy loading could fail anyway.) If
you have access to the hibernate mapping just set lazy="false" on your class
mappings.
Not to say that this use case shouldn't be addressed with drools, but if you're
under a deadline... :)
--- On Mon, 5/4/09, Guto <guto(a)guto.net> wrote:
From: Guto <guto(a)guto.net>
Subject: Re: [rules-users] Hibernate proxy objects equality tests failing in Drools 5
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Date: Monday, May 4, 2009, 2:42 PM
Just now I notice one thing. The application that i am
building is
compleatly EJB centric. I have um EJB project that usually
do all the
database stuff, and another EJB project for the drools
rules. Lets call
them
EJB-DATA and EJB-DROOLS. When the client calls for an
specific data that
must be threated thru the Drools rules it calls an
Stateless method from
EJB-DATA, inside the method, it gather the necessarie
parameter
information and them inside the EJB-DATA method it calls
the EJB-DROOLS.
(hoping not been confusing)
(if you are using an fixed space font, here comes the
sequence)
Client --> EJB-DATA (gather information inside) -->
EJB-DROOLS
<-- return to Client data from EJB-DROOLS<--
return to EJB-DATA
Now looking over my two projects, I notice that I make them
apart so one
could evolve with interfering the other.
When I call EJB-DROOLS directly from an UNIT-TEST client
with pojos
parameters intantiated by the test, it pass.
When I call EJB-DATA from an UNIT-TEST client (pojos
created inside this),
first i was getting an CORBA exception ´cause of a
ClassNotFoundException
for the hibernate PersistenceBag.
That´s the way i figure out that my objects are bagged or
proxied thru
hibernate.
I´ve tried to use the EntityManager.clear() (EJB3-JPA) to
clean the pojos
before send it and make them more like the ones from the
first unit-test,
but even so it´s not working.
Then, possible solutions:
1) Make equality test works from objects that came from
hibernate from jpa.
2) Kill the proxies and make them simple objects (not
hibernate derivated).
3) don´t know, but i´m been realy in a deadline here.
again
thanks for anyone in advance !
--
Guto Maia
Consultor de TI / Desenvolvedor
CSM - SCJP- SCWCD - SCBCD - ZCE
> In fact, i´m really using JPA with hibernate as an
provider.
>
> Could you send me your hibernate config? I will
compare some proprieties
> of tyour hibernate.config with my persistence.xml.
>
> I plenty sure that the rule is ok, since it is working
with the unit test.
>
> If you need any help to mimic what your using with
JPA, just ask.
>
> Thanks anyway.
>
>
>>
>> I'm using non-proxied hibernate backed POJOs
in drools with no problems.
>> (THe pojos aer generaed by hbm2java.) I'll
try configuring for proxies
>> to
>> see what happens.
>>
>>
>> --- On Mon, 5/4/09, Gustavo Maia Neto
<guto(a)guto.net> wrote:
>>
>>> From: Gustavo Maia Neto <guto(a)guto.net>
>>> Subject: Re: [rules-users] Hibernate proxy
objects equality tests
>>> failing in Drools 5
>>> To: "Rules Users List"
<rules-users(a)lists.jboss.org>
>>> Date: Monday, May 4, 2009, 11:28 AM
>>> on this afternoon I will migrate to Drools 5
CR1,
>>> unfortunelly i'm not
>>> sure if it will solve my problem.
>>>
>>> Does anyone else uses Drools with objects that
came from an
>>> hibernate,
>>> (proxies)?
>>>
>>> Also, i'm not using any proxy to fetch
lazy data inside
>>> my Drools
>>> stateful session.
>>>
>>> thanks
>>>
>>> Guto escreveu:
>>> > I was following that subject on markmail,
and them
>>> I've enterred the
>>> > user-group (so subject and body are
coppied from
>>> them). I've got the
>>> > exactly same problem. When I use the
rules with
>>> objects the came from the
>>> > database (thru JPA hibernate provider),
thouse rules
>>> never match. When I
>>> > do the same from Pojos hand made for unit
test, it
>>> work.
>>> >
>>> > I don't know what really happen, but
i'm sure
>>> that it is an equality test
>>> > falling 'cause of the hibernate
proxys.
>>> >
>>> > I don't get also any kind of error or
exception,
>>> since it ALL WORK. Just
>>> > the rule isn't be acomplished.
>>> >
>>> > I'm using EJB3 + JPA (hibernate
provider) and
>>> Drools 4 GA;
>>> >
>>> > thanks in advance for any help
>>> >
>>>
>>>
_______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> --
> Guto Maia
> Consultor de TI / Desenvolvedor
> CSM - SCJP- SCWCD - SCBCD - ZCE
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users