You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by himadri <hi...@yahoo.co.in> on 2009/12/01 14:15:49 UTC

Open JPA generates incorrect Union All for Date and Boolean Datatype

Hi,

I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB. I
have an entity Typed which has Date and Boolean datatypes. em.persist is
sucessful.

But whereever there is em.find() on any entity in this application , I have
observed that open JPA  tries to get Union  of all entities. This may be
because its first time , But it fails with exception

"[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same
datatype as corresponding expression"

The SQL generated is union all of all entities in the application . For
boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date
function for date. I have used DATE and boolean in Entity class.

SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01',
'', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
UNION ALL 
SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F,
t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0
WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790, state=HY000]

I guess openJPA fails to add to_date function for DATE and surrounding chars
for boolean. Is this a bug or some settings available.  Why is it trying to
get union all even for em.find(... ) ?

Thanks in advance.. 
- H






-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Ravi P Palacherla <ra...@oracle.com>.
Hi Himadri,

I am able to replicate the issue even after adding
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> 

I will look into it further and will give you an update if I find anything
useful.

Regards,
Ravi.


Himadri wrote:
> 
> 
> 
> Hi,
> 
> This is strange. The problem comes when I add Child Associations to the
> entity. If I remove Child Asscoiations , all work fine. I have attached my
> Sample here. 
> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
> ear on WL10.3. 
> 
> Let me know if you find out anything .. for now I have replace all em.find
> with em.createQuery(Select ...) , But will like to know the real reason
> behind it ! 
> 
> Lemme know if I can provide more simplified sample ....
> 
> Thanks,
> Himadri 
> 
> 
> ________________________________
> From: Kevin Sutter [via OpenJPA]
> <ml...@n2.nabble.com>
> To: himadri <hi...@yahoo.co.in>
> Sent: Thu, 3 December, 2009 5:39:17 AM
> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
> Datatype
> 
> This sounds very strange.  From your description, I have no idea why Date 
> and Boolean attributes are having problems with Oracle.  And, why a Union 
> All is being generated for a simple find operation baffles me as well. 
> Unless there is some inheritance or eagerly fetched relationships
> involved. 
> Still, I thought OpenJPA used Joins over Unions. 
> 
> Can you simplify the problem to a simple testcase that could be provided? 
> 
> Thanks, 
> Kevin 
> 
> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
> 
> 
>> 
>> Hi, 
>> 
>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB.
>> I 
>> have an entity Typed which has Date and Boolean datatypes. em.persist is 
>> sucessful. 
>> 
>> But whereever there is em.find() on any entity in this application , I
>> have 
>> observed that open JPA  tries to get Union  of all entities. This may be 
>> because its first time , But it fails with exception 
>> 
>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>> datatype as corresponding expression" 
>> 
>> The SQL generated is union all of all entities in the application . For 
>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date 
>> function for date. I have used DATE and boolean in Entity class. 
>> 
>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>> '1970-01-01', 
>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>> UNION ALL 
>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>> t0.ENUMED1_F, 
>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T
>> t0 
>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>> state=HY000] 
>> 
>> I guess openJPA fails to add to_date function for DATE and surrounding 
>> chars 
>> for boolean. Is this a bug or some settings available.  Why is it trying
>> to 
>> get union all even for em.find(... ) ? 
>> 
>> Thanks in advance.. 
>> - H 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> View this message in context: 
>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>> 
> 
> 
> ________________________________
> 
> View message @
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
> To unsubscribe from Open JPA generates incorrect Union All for Date and
> Boolean Datatype, click here. 
> 
> 
> 
>       The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/
>  
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4149331.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Kevin Sutter <kw...@gmail.com>.
Hi,
Something didn't work with your attachment.  I don't see anything attached
to your note.

I don't have any other ideas at the moment.  I will copy Ravi on this reply
since he's our WebLogic expert.  He might know of something unique to this
environment that is causing this anomaly.

Good luck,
Kevin

On Mon, Dec 7, 2009 at 8:22 AM, himadri <hi...@yahoo.co.in> wrote:

>
>
>
> Hi,
>
> This is strange. The problem comes when I add Child Associations to the
> entity. If I remove Child Asscoiations , all work fine. I have attached my
> Sample here.
> Please see JPG for Entity Associations. SampleEJB.ear is the deployable ear
> on WL10.3.
>
> Let me know if you find out anything .. for now I have replace all em.find
> with em.createQuery(Select ...) , But will like to know the real reason
> behind it !
>
> Lemme know if I can provide more simplified sample ....
>
> Thanks,
> Himadri
>
>
> ________________________________
> From: Kevin Sutter [via OpenJPA] <ml...@n2.nabble.com>
> >
> To: himadri <hi...@yahoo.co.in>
> Sent: Thu, 3 December, 2009 5:39:17 AM
> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
> Datatype
>
> This sounds very strange.  From your description, I have no idea why Date
> and Boolean attributes are having problems with Oracle.  And, why a Union
> All is being generated for a simple find operation baffles me as well.
> Unless there is some inheritance or eagerly fetched relationships involved.
> Still, I thought OpenJPA used Joins over Unions.
>
> Can you simplify the problem to a simple testcase that could be provided?
>
> Thanks,
> Kevin
>
> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote:
>
>
> >
> > Hi,
> >
> > I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB.
> I
> > have an entity Typed which has Date and Boolean datatypes. em.persist is
> > sucessful.
> >
> > But whereever there is em.find() on any entity in this application , I
> have
> > observed that open JPA  tries to get Union  of all entities. This may be
> > because its first time , But it fails with exception
> >
> > "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same
> > datatype as corresponding expression"
> >
> > The SQL generated is union all of all entities in the application . For
> > boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date
> > function for date. I have used DATE and boolean in Entity class.
> >
> > SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0,
> > '1970-01-01',
> > '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ?
> > UNION ALL
> > SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
> t0.ENUMED1_F,
> > t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T
> t0
> > WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
> state=HY000]
> >
> > I guess openJPA fails to add to_date function for DATE and surrounding
> > chars
> > for boolean. Is this a bug or some settings available.  Why is it trying
> to
> > get union all even for em.find(... ) ?
> >
> > Thanks in advance..
> > - H
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >
>
>
> ________________________________
>
> View message @
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html
> To unsubscribe from Open JPA generates incorrect Union All for Date and
> Boolean Datatype, click here.
>
>
>
>      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/
>
> --
> View this message in context:
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4126266.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Ravi,
Could you summarize the situation in a reply?  I understand that the default
value for SubclassFetchMode is incorrectly documented (or implemented,
depending on your perspective).  But, is the "kodo wrapper" affecting how
OpenJPA generates the SQL for this situation?  That's the part I'm confused
on.  Thanks.

Kevink

On Fri, Dec 11, 2009 at 1:15 AM, Ravi Palacherla <ravi.palacherla@oracle.com
> wrote:

> Hi Himadri,
>
> Good to know that it works.
>
> I think kodo uses UNIONs with subclassFetchMode as join.
>
> So, somehow the kodo configuration (which internally again uses openJPA) is
> being picked up and hence you are seeing UNIONs in the sql statements.
>
> I will see if there is a way to use only openJPA without kodo coming into
> the picture at all on weblogic.
>
> Regards,
> Ravi.
>
> -----Original Message-----
> From: Himadri [mailto:hima_das@yahoo.co.in]
> Sent: Thursday, December 10, 2009 11:11 PM
> To: users@openjpa.apache.org
> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
> Datatype
>
>
> Hi Ravi ,
>
> Thanks ! It worked with none. I need to run all the test cases to see this
> is not breaking others.
>
> Yes , the default behaviour is JOIN not parallel , but User Guide mentions
> parallel as default. We dont want JOIN. I have put it as none for now.
>
> All Entities extends EntityBase which has common attribute like id and
> version. Do you think this is not a good way to implement ?
>
>
> Ravi P Palacherla wrote:
> >
> > Hi Himadri,
> >
> > Here are answers for some of your questions:
> >
> >>> Why is it trying to get union all even for em.find(... ) ?
> >
> > In your application all the entities ( E.g: AddOn.java, Typed.java) are
> > all subclasses of EntityBase.
> >
> > If you use either of the following property:
> > <property name="openjpa.jdbc.SubclassFetchMode" value="parallel"/>
> > or
> > <property name="openjpa.jdbc.SubclassFetchMode" value="none"/>
> > then you will not see the error.
> >
> > If you use parallel, then seperate select statements are used to eager
> > fetch data for subclasses
> > and if you use "none" then I guess it will no try to fetch the
> subclasses.
> > so, you can use any of the above properties to fix your issue.
> >
> > The third type of SubclassFetchMode is "join" and even though the
> > documentation claims that "parallel" is default mode
> >
> http://openjpa.apache.org/builds/1.1.0/apache-openjpa-1.1.0/docs/manual/manual.html#openjpa.jdbc.SubclassFetchMode
> > The default looks like "join" mode.
> >
> > So if using any of the above properties is acceptable to you then please
> > use it.
> >
> > If you must use "JOIN" then please let me know and I will spend more time
> > to find the cause of the issue.
> >
> > Regards,
> > Ravi.
> >
> >
> >
> >
> >
> > Himadri wrote:
> >>
> >> So sorry .. attached the wrong one .. Please see the correct one here.If
> >> I run the junit , I get this exception "javax.ejb.EJBException: EJB
> >> Exception: ; nested exception is:
> >>      <openjpa-1.1.0-r422266:657916 nonfatal general error>
> >> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
> >> Driver][Oracle]ORA-01790: expression must have same datatype as
> >> corresponding expression
> >>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> >> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
> >> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
> >> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID =
> ?
> >> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> >> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> >> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> >> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
> >> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID,
> t0.version,
> >> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
> >> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID,
> t0.version,
> >> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
> >> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE
> t0.ID
> >> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> >>      at
> >>
> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
> >>      at
> >>
> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
> >>      at $Proxy0.testType(Unknown Source)
> >>      at com.tieto.magic.poc.test.TestSample.testP(TestSample.java:54)
> >>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>      at
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>      at
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at junit.framework.TestCase.runTest(TestCase.java:168)
> >>      at junit.framework.TestCase.runBare(TestCase.java:134)
> >>      at junit.framework.TestResult$1.protect(TestResult.java:110)
> >>      at junit.framework.TestResult.runProtected(TestResult.java:128)
> >>      at junit.framework.TestResult.run(TestResult.java:113)
> >>      at junit.framework.TestCase.run(TestCase.java:124)
> >>      at junit.framework.TestSuite.runTest(TestSuite.java:232)
> >>      at junit.framework.TestSuite.run(TestSuite.java:227)
> >>      at
> >>
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> >>      at
> >>
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> >>      at
> >>
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> >>      at
> >>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> >>      at
> >>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> >>      at
> >>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> >>      at
> >>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> >> Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error>
> >> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
> >> Driver][Oracle]ORA-01790: expression must have same datatype as
> >> corresponding expression
> >>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> >> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
> >> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
> >> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID =
> ?
> >> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> >> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> >> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> >> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
> >> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID,
> t0.version,
> >> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
> >> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID,
> t0.version,
> >> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
> >> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE
> t0.ID
> >> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> >>      at
> >> org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
> >>      at
> >>
> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
> >>      at
> >>
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
> >>      at
> >>
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
> >>      at
> >>
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
> >>      at
> >>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:268)
> >>      at
> >>
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> >>      at
> >>
> org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:336)
> >>      at
> >>
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> >>      at
> >>
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> >>      at
> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
> >>      at kodo.kernel.KodoBroker.initialize(KodoBroker.java:65)
> >>      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
> >>      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:769)
> >>      at kodo.kernel.KodoBroker.find(KodoBroker.java:232)
> >>      at
> >>
> org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:183)
> >>      at
> >>
> org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:452)
> >>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>      at
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>      at
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >>
> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90)
> >>      at
> >>
> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)
> >>      at
> >>
> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
> >>      at
> >>
> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)
> >>      at $Proxy140.find(Unknown Source)
> >>      at
> >>
> com.tieto.magic.poc.domain.DomainServicesBean.testType(DomainServicesBean.java:48)
> >>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>      at
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>      at
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> >>      at
> >>
> com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
> >>      at
> >>
> weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
> >>      at
> >>
> com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> >>      at
> >>
> com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
> >>      at $Proxy142.testType(Unknown Source)
> >>      at
> >>
> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl.testType(DomainServicesBean_au5mn8_DomainServicesRImpl.java:65)
> >>      at
> >>
> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl_WLSkel.invoke(Unknown
> >> Source)
> >>      at
> weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
> >>      at
> >>
> weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
> >>      at
> weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
> >>      at
> >>
> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
> >>      at weblogic.security.service.SecurityManager.runAs(Unknown Source)
> >>      at
> >>
> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
> >>      at
> >>
> weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
> >>      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
> >>      at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
> >> Caused by: java.lang.Exception:
> >> org.apache.openjpa.lib.jdbc.ReportingSQLException: [BEA][Oracle JDBC
> >> Driver][Oracle]ORA-01790: expression must have same datatype as
> >> corresponding expression
> >>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> >> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
> >> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
> >> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID =
> ?
> >> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> >> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> >> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> >> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
> >> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID,
> t0.version,
> >> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
> >> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID,
> t0.version,
> >> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
> >> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE
> t0.ID
> >> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A, (String)
> >> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> >>      at
> >>
> org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:249)
> >>      at
> >>
> org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
> >>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>      at
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>      at
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>      at java.lang.reflect.Method.invoke(Method.java:597)
> >>      at
> >> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
> >>      at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
> >>      at
> >>
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
> >>      at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
> >>      at
> >>
> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
> >>      at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
> >>      at
> >>
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
> >>      at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
> >>      at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
> >>      at
> >>
> weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
> >>      at
> >>
> weblogic.rjvm.MsgAbbrevOutputStream.sendThrowable(MsgAbbrevOutputStream.java:471)
> >>      at
> >>
> weblogic.rmi.internal.BasicServerRef.handleThrowable(BasicServerRef.java:694)
> >>      at
> >> weblogic.rmi.internal.BasicServerRef.postInvoke(BasicServerRef.java:650)
> >>      at
> >>
> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:492)
> >>      ... 3 more
> >>
> >> "
> >>
> >>  http://n2.nabble.com/file/n4138239/SampleEJBEar.ear SampleEJBEar.ear
> >>
> >> Ravi P Palacherla wrote:
> >>>
> >>> Looks like the SampleEJB.ear in the attachment is not a correct ear.
> >>> I am unable to deploy it on Weblogic server.
> >>>
> >>> Also the configuration files (like persistence.xml) and entities are
> >>> missing in the attachment without which I may not be able to tell what
> >>> configuration you are using.
> >>>
> >>> Are you using openJPA configurations or kodo configurations ?
> >>> There was a known issue with a CLOB data type when kodo configuration
> is
> >>> used.
> >>> The fix for this is in kodo files, it overrides openJPA's classes in
> >>> order to fix it.
> >>>
> >>> Before going into details of the fix, Please attach a replicable
> >>> testcase.
> >>> That way I can see if the same fix applies for your scenario or not.
> >>>
> >>> It would be great if you are able to replicate the issue with openJPA
> >>> configuration itself; we can work together on resolving the issue in
> >>> openJPA itself.
> >>>
> >>> Also there were some workarounds of setting
> >>> "SubclassFetchMode=none";which I would not completely recommend with
> out
> >>> understanding your complete environment.
> >>>
> >>> Regards,
> >>> Ravi.
> >>>
> >>>
> >>> himadri wrote:
> >>>>
> >>>>
> >>>>
> >>>> Hi,
> >>>>
> >>>> This is strange. The problem comes when I add Child Associations to
> the
> >>>> entity. If I remove Child Asscoiations , all work fine. I have
> attached
> >>>> my Sample here.
> >>>> Please see JPG for Entity Associations. SampleEJB.ear is the
> deployable
> >>>> ear on WL10.3.
> >>>>
> >>>> Let me know if you find out anything .. for now I have replace all
> >>>> em.find with em.createQuery(Select ...) , But will like to know the
> >>>> real reason behind it !
> >>>>
> >>>> Lemme know if I can provide more simplified sample ....
> >>>>
> >>>> Thanks,
> >>>> Himadri
> >>>>
> >>>>
> >>>> ________________________________
> >>>> From: Kevin Sutter [via OpenJPA]
> >>>> <ml...@n2.nabble.com>
> >
> >>>> To: himadri <hi...@yahoo.co.in>
> >>>> Sent: Thu, 3 December, 2009 5:39:17 AM
> >>>> Subject: Re: Open JPA generates incorrect Union All for Date and
> >>>> Boolean Datatype
> >>>>
> >>>> This sounds very strange.  From your description, I have no idea why
> >>>> Date
> >>>> and Boolean attributes are having problems with Oracle.  And, why a
> >>>> Union
> >>>> All is being generated for a simple find operation baffles me as well.
> >>>> Unless there is some inheritance or eagerly fetched relationships
> >>>> involved.
> >>>> Still, I thought OpenJPA used Joins over Unions.
> >>>>
> >>>> Can you simplify the problem to a simple testcase that could be
> >>>> provided?
> >>>>
> >>>> Thanks,
> >>>> Kevin
> >>>>
> >>>> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote:
> >>>>
> >>>>
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g
> >>>>> DB. I
> >>>>> have an entity Typed which has Date and Boolean datatypes. em.persist
> >>>>> is
> >>>>> sucessful.
> >>>>>
> >>>>> But whereever there is em.find() on any entity in this application ,
> I
> >>>>> have
> >>>>> observed that open JPA  tries to get Union  of all entities. This may
> >>>>> be
> >>>>> because its first time , But it fails with exception
> >>>>>
> >>>>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same
> >>>>> datatype as corresponding expression"
> >>>>>
> >>>>> The SQL generated is union all of all entities in the application .
> >>>>> For
> >>>>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have
> >>>>> to_date
> >>>>> function for date. I have used DATE and boolean in Entity class.
> >>>>>
> >>>>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0,
> >>>>> '1970-01-01',
> >>>>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ?
> >>>>> UNION ALL
> >>>>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
> >>>>> t0.ENUMED1_F,
> >>>>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM
> >>>>> TYPED_T t0
> >>>>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
> >>>>> state=HY000]
> >>>>>
> >>>>> I guess openJPA fails to add to_date function for DATE and
> surrounding
> >>>>> chars
> >>>>> for boolean. Is this a bug or some settings available.  Why is it
> >>>>> trying to
> >>>>> get union all even for em.find(... ) ?
> >>>>>
> >>>>> Thanks in advance..
> >>>>> - H
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> View this message in context:
> >>>>>
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
> >>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >>>>>
> >>>>
> >>>>
> >>>> ________________________________
> >>>>
> >>>> View message @
> >>>>
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html
> >>>> To unsubscribe from Open JPA generates incorrect Union All for Date
> and
> >>>> Boolean Datatype, click here.
> >>>>
> >>>>
> >>>>
> >>>>       The INTERNET now has a personality. YOURS! See your Yahoo!
> >>>> Homepage. http://in.yahoo.com/
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4149660.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

RE: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Ravi Palacherla <ra...@oracle.com>.
Hi Himadri,

Good to know that it works.

I think kodo uses UNIONs with subclassFetchMode as join.

So, somehow the kodo configuration (which internally again uses openJPA) is being picked up and hence you are seeing UNIONs in the sql statements.

I will see if there is a way to use only openJPA without kodo coming into the picture at all on weblogic.

Regards,
Ravi.

-----Original Message-----
From: Himadri [mailto:hima_das@yahoo.co.in] 
Sent: Thursday, December 10, 2009 11:11 PM
To: users@openjpa.apache.org
Subject: Re: Open JPA generates incorrect Union All for Date and Boolean Datatype


Hi Ravi ,

Thanks ! It worked with none. I need to run all the test cases to see this
is not breaking others.

Yes , the default behaviour is JOIN not parallel , but User Guide mentions
parallel as default. We dont want JOIN. I have put it as none for now. 

All Entities extends EntityBase which has common attribute like id and
version. Do you think this is not a good way to implement ? 


Ravi P Palacherla wrote:
> 
> Hi Himadri,
> 
> Here are answers for some of your questions:
> 
>>> Why is it trying to get union all even for em.find(... ) ? 
> 
> In your application all the entities ( E.g: AddOn.java, Typed.java) are
> all subclasses of EntityBase.
> 
> If you use either of the following property:
> <property name="openjpa.jdbc.SubclassFetchMode" value="parallel"/>
> or
> <property name="openjpa.jdbc.SubclassFetchMode" value="none"/>
> then you will not see the error.
> 
> If you use parallel, then seperate select statements are used to eager
> fetch data for subclasses 
> and if you use "none" then I guess it will no try to fetch the subclasses.
> so, you can use any of the above properties to fix your issue.
> 
> The third type of SubclassFetchMode is "join" and even though the
> documentation claims that "parallel" is default mode 
> http://openjpa.apache.org/builds/1.1.0/apache-openjpa-1.1.0/docs/manual/manual.html#openjpa.jdbc.SubclassFetchMode
> The default looks like "join" mode.
> 
> So if using any of the above properties is acceptable to you then please
> use it.
> 
> If you must use "JOIN" then please let me know and I will spend more time
> to find the cause of the issue.
> 
> Regards,
> Ravi.
> 
> 
> 
> 
> 
> Himadri wrote:
>> 
>> So sorry .. attached the wrong one .. Please see the correct one here.If
>> I run the junit , I get this exception "javax.ejb.EJBException: EJB
>> Exception: ; nested exception is: 
>> 	<openjpa-1.1.0-r422266:657916 nonfatal general error>
>> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
>> Driver][Oracle]ORA-01790: expression must have same datatype as
>> corresponding expression
>>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
>> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
>> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
>> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
>> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
>> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
>> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
>> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
>> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version,
>> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
>> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID
>> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
>> 	at
>> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
>> 	at
>> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
>> 	at $Proxy0.testType(Unknown Source)
>> 	at com.tieto.magic.poc.test.TestSample.testP(TestSample.java:54)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at junit.framework.TestCase.runTest(TestCase.java:168)
>> 	at junit.framework.TestCase.runBare(TestCase.java:134)
>> 	at junit.framework.TestResult$1.protect(TestResult.java:110)
>> 	at junit.framework.TestResult.runProtected(TestResult.java:128)
>> 	at junit.framework.TestResult.run(TestResult.java:113)
>> 	at junit.framework.TestCase.run(TestCase.java:124)
>> 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
>> 	at junit.framework.TestSuite.run(TestSuite.java:227)
>> 	at
>> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
>> 	at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>> Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error>
>> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
>> Driver][Oracle]ORA-01790: expression must have same datatype as
>> corresponding expression
>>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
>> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
>> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
>> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
>> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
>> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
>> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
>> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
>> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version,
>> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
>> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID
>> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
>> 	at
>> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
>> 	at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:268)
>> 	at
>> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
>> 	at
>> org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:336)
>> 	at
>> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
>> 	at
>> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
>> 	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
>> 	at kodo.kernel.KodoBroker.initialize(KodoBroker.java:65)
>> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
>> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:769)
>> 	at kodo.kernel.KodoBroker.find(KodoBroker.java:232)
>> 	at
>> org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:183)
>> 	at
>> org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:452)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at
>> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90)
>> 	at
>> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)
>> 	at
>> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
>> 	at
>> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)
>> 	at $Proxy140.find(Unknown Source)
>> 	at
>> com.tieto.magic.poc.domain.DomainServicesBean.testType(DomainServicesBean.java:48)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
>> 	at
>> weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
>> 	at
>> com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
>> 	at $Proxy142.testType(Unknown Source)
>> 	at
>> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl.testType(DomainServicesBean_au5mn8_DomainServicesRImpl.java:65)
>> 	at
>> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl_WLSkel.invoke(Unknown
>> Source)
>> 	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
>> 	at
>> weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
>> 	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
>> 	at
>> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
>> 	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
>> 	at
>> weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
>> 	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
>> 	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>> Caused by: java.lang.Exception:
>> org.apache.openjpa.lib.jdbc.ReportingSQLException: [BEA][Oracle JDBC
>> Driver][Oracle]ORA-01790: expression must have same datatype as
>> corresponding expression
>>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
>> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
>> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
>> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
>> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
>> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
>> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
>> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
>> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version,
>> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
>> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID
>> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
>> 	at
>> org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:249)
>> 	at
>> org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at
>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
>> 	at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
>> 	at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>> 	at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
>> 	at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
>> 	at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>> 	at
>> weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
>> 	at
>> weblogic.rjvm.MsgAbbrevOutputStream.sendThrowable(MsgAbbrevOutputStream.java:471)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.handleThrowable(BasicServerRef.java:694)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.postInvoke(BasicServerRef.java:650)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:492)
>> 	... 3 more
>> 
>> "
>> 
>>  http://n2.nabble.com/file/n4138239/SampleEJBEar.ear SampleEJBEar.ear 
>> 
>> Ravi P Palacherla wrote:
>>> 
>>> Looks like the SampleEJB.ear in the attachment is not a correct ear.
>>> I am unable to deploy it on Weblogic server.
>>> 
>>> Also the configuration files (like persistence.xml) and entities are
>>> missing in the attachment without which I may not be able to tell what
>>> configuration you are using.
>>> 
>>> Are you using openJPA configurations or kodo configurations ?
>>> There was a known issue with a CLOB data type when kodo configuration is
>>> used. 
>>> The fix for this is in kodo files, it overrides openJPA's classes in
>>> order to fix it.
>>> 
>>> Before going into details of the fix, Please attach a replicable
>>> testcase.
>>> That way I can see if the same fix applies for your scenario or not.
>>> 
>>> It would be great if you are able to replicate the issue with openJPA
>>> configuration itself; we can work together on resolving the issue in
>>> openJPA itself.
>>> 
>>> Also there were some workarounds of setting
>>> "SubclassFetchMode=none";which I would not completely recommend with out
>>> understanding your complete environment.
>>> 
>>> Regards,
>>> Ravi.
>>> 
>>> 
>>> himadri wrote:
>>>> 
>>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> This is strange. The problem comes when I add Child Associations to the
>>>> entity. If I remove Child Asscoiations , all work fine. I have attached
>>>> my Sample here. 
>>>> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
>>>> ear on WL10.3. 
>>>> 
>>>> Let me know if you find out anything .. for now I have replace all
>>>> em.find with em.createQuery(Select ...) , But will like to know the
>>>> real reason behind it ! 
>>>> 
>>>> Lemme know if I can provide more simplified sample ....
>>>> 
>>>> Thanks,
>>>> Himadri 
>>>> 
>>>> 
>>>> ________________________________
>>>> From: Kevin Sutter [via OpenJPA]
>>>> <ml...@n2.nabble.com>
>>>> To: himadri <hi...@yahoo.co.in>
>>>> Sent: Thu, 3 December, 2009 5:39:17 AM
>>>> Subject: Re: Open JPA generates incorrect Union All for Date and
>>>> Boolean Datatype
>>>> 
>>>> This sounds very strange.  From your description, I have no idea why
>>>> Date 
>>>> and Boolean attributes are having problems with Oracle.  And, why a
>>>> Union 
>>>> All is being generated for a simple find operation baffles me as well. 
>>>> Unless there is some inheritance or eagerly fetched relationships
>>>> involved. 
>>>> Still, I thought OpenJPA used Joins over Unions. 
>>>> 
>>>> Can you simplify the problem to a simple testcase that could be
>>>> provided? 
>>>> 
>>>> Thanks, 
>>>> Kevin 
>>>> 
>>>> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
>>>> 
>>>> 
>>>>> 
>>>>> Hi, 
>>>>> 
>>>>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g
>>>>> DB. I 
>>>>> have an entity Typed which has Date and Boolean datatypes. em.persist
>>>>> is 
>>>>> sucessful. 
>>>>> 
>>>>> But whereever there is em.find() on any entity in this application , I
>>>>> have 
>>>>> observed that open JPA  tries to get Union  of all entities. This may
>>>>> be 
>>>>> because its first time , But it fails with exception 
>>>>> 
>>>>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>>>>> datatype as corresponding expression" 
>>>>> 
>>>>> The SQL generated is union all of all entities in the application .
>>>>> For 
>>>>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have
>>>>> to_date 
>>>>> function for date. I have used DATE and boolean in Entity class. 
>>>>> 
>>>>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>>>>> '1970-01-01', 
>>>>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>>>>> UNION ALL 
>>>>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>>>>> t0.ENUMED1_F, 
>>>>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM
>>>>> TYPED_T t0 
>>>>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>>>>> state=HY000] 
>>>>> 
>>>>> I guess openJPA fails to add to_date function for DATE and surrounding 
>>>>> chars 
>>>>> for boolean. Is this a bug or some settings available.  Why is it
>>>>> trying to 
>>>>> get union all even for em.find(... ) ? 
>>>>> 
>>>>> Thanks in advance.. 
>>>>> - H 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> View this message in context: 
>>>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>>>>> 
>>>> 
>>>> 
>>>> ________________________________
>>>> 
>>>> View message @
>>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
>>>> To unsubscribe from Open JPA generates incorrect Union All for Date and
>>>> Boolean Datatype, click here. 
>>>> 
>>>> 
>>>> 
>>>>       The INTERNET now has a personality. YOURS! See your Yahoo!
>>>> Homepage. http://in.yahoo.com/
>>>>  
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4149660.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Himadri <hi...@yahoo.co.in>.
Hi Ravi ,

Thanks ! It worked with none. I need to run all the test cases to see this
is not breaking others.

Yes , the default behaviour is JOIN not parallel , but User Guide mentions
parallel as default. We dont want JOIN. I have put it as none for now. 

All Entities extends EntityBase which has common attribute like id and
version. Do you think this is not a good way to implement ? 


Ravi P Palacherla wrote:
> 
> Hi Himadri,
> 
> Here are answers for some of your questions:
> 
>>> Why is it trying to get union all even for em.find(... ) ? 
> 
> In your application all the entities ( E.g: AddOn.java, Typed.java) are
> all subclasses of EntityBase.
> 
> If you use either of the following property:
> <property name="openjpa.jdbc.SubclassFetchMode" value="parallel"/>
> or
> <property name="openjpa.jdbc.SubclassFetchMode" value="none"/>
> then you will not see the error.
> 
> If you use parallel, then seperate select statements are used to eager
> fetch data for subclasses 
> and if you use "none" then I guess it will no try to fetch the subclasses.
> so, you can use any of the above properties to fix your issue.
> 
> The third type of SubclassFetchMode is "join" and even though the
> documentation claims that "parallel" is default mode 
> http://openjpa.apache.org/builds/1.1.0/apache-openjpa-1.1.0/docs/manual/manual.html#openjpa.jdbc.SubclassFetchMode
> The default looks like "join" mode.
> 
> So if using any of the above properties is acceptable to you then please
> use it.
> 
> If you must use "JOIN" then please let me know and I will spend more time
> to find the cause of the issue.
> 
> Regards,
> Ravi.
> 
> 
> 
> 
> 
> Himadri wrote:
>> 
>> So sorry .. attached the wrong one .. Please see the correct one here.If
>> I run the junit , I get this exception "javax.ejb.EJBException: EJB
>> Exception: ; nested exception is: 
>> 	<openjpa-1.1.0-r422266:657916 nonfatal general error>
>> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
>> Driver][Oracle]ORA-01790: expression must have same datatype as
>> corresponding expression
>>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
>> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
>> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
>> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
>> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
>> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
>> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
>> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
>> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version,
>> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
>> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID
>> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
>> 	at
>> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
>> 	at
>> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
>> 	at $Proxy0.testType(Unknown Source)
>> 	at com.tieto.magic.poc.test.TestSample.testP(TestSample.java:54)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at junit.framework.TestCase.runTest(TestCase.java:168)
>> 	at junit.framework.TestCase.runBare(TestCase.java:134)
>> 	at junit.framework.TestResult$1.protect(TestResult.java:110)
>> 	at junit.framework.TestResult.runProtected(TestResult.java:128)
>> 	at junit.framework.TestResult.run(TestResult.java:113)
>> 	at junit.framework.TestCase.run(TestCase.java:124)
>> 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
>> 	at junit.framework.TestSuite.run(TestSuite.java:227)
>> 	at
>> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
>> 	at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>> 	at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>> Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error>
>> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
>> Driver][Oracle]ORA-01790: expression must have same datatype as
>> corresponding expression
>>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
>> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
>> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
>> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
>> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
>> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
>> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
>> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
>> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version,
>> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
>> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID
>> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
>> 	at
>> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
>> 	at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
>> 	at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:268)
>> 	at
>> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
>> 	at
>> org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:336)
>> 	at
>> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
>> 	at
>> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
>> 	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
>> 	at kodo.kernel.KodoBroker.initialize(KodoBroker.java:65)
>> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
>> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:769)
>> 	at kodo.kernel.KodoBroker.find(KodoBroker.java:232)
>> 	at
>> org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:183)
>> 	at
>> org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:452)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at
>> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90)
>> 	at
>> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)
>> 	at
>> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
>> 	at
>> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)
>> 	at $Proxy140.find(Unknown Source)
>> 	at
>> com.tieto.magic.poc.domain.DomainServicesBean.testType(DomainServicesBean.java:48)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
>> 	at
>> weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
>> 	at
>> com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
>> 	at
>> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
>> 	at
>> com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
>> 	at $Proxy142.testType(Unknown Source)
>> 	at
>> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl.testType(DomainServicesBean_au5mn8_DomainServicesRImpl.java:65)
>> 	at
>> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl_WLSkel.invoke(Unknown
>> Source)
>> 	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
>> 	at
>> weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
>> 	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
>> 	at
>> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
>> 	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
>> 	at
>> weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
>> 	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
>> 	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>> Caused by: java.lang.Exception:
>> org.apache.openjpa.lib.jdbc.ReportingSQLException: [BEA][Oracle JDBC
>> Driver][Oracle]ORA-01790: expression must have same datatype as
>> corresponding expression
>>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
>> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID
>> = ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '',
>> 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
>> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
>> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
>> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
>> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
>> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0
>> FROM SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version,
>> '', '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F,
>> t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID
>> = ? [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A, (String)
>> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
>> 	at
>> org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:249)
>> 	at
>> org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> 	at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> 	at java.lang.reflect.Method.invoke(Method.java:597)
>> 	at
>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
>> 	at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
>> 	at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>> 	at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
>> 	at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
>> 	at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>> 	at
>> weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
>> 	at
>> weblogic.rjvm.MsgAbbrevOutputStream.sendThrowable(MsgAbbrevOutputStream.java:471)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.handleThrowable(BasicServerRef.java:694)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.postInvoke(BasicServerRef.java:650)
>> 	at
>> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:492)
>> 	... 3 more
>> 
>> "
>> 
>>  http://n2.nabble.com/file/n4138239/SampleEJBEar.ear SampleEJBEar.ear 
>> 
>> Ravi P Palacherla wrote:
>>> 
>>> Looks like the SampleEJB.ear in the attachment is not a correct ear.
>>> I am unable to deploy it on Weblogic server.
>>> 
>>> Also the configuration files (like persistence.xml) and entities are
>>> missing in the attachment without which I may not be able to tell what
>>> configuration you are using.
>>> 
>>> Are you using openJPA configurations or kodo configurations ?
>>> There was a known issue with a CLOB data type when kodo configuration is
>>> used. 
>>> The fix for this is in kodo files, it overrides openJPA's classes in
>>> order to fix it.
>>> 
>>> Before going into details of the fix, Please attach a replicable
>>> testcase.
>>> That way I can see if the same fix applies for your scenario or not.
>>> 
>>> It would be great if you are able to replicate the issue with openJPA
>>> configuration itself; we can work together on resolving the issue in
>>> openJPA itself.
>>> 
>>> Also there were some workarounds of setting
>>> "SubclassFetchMode=none";which I would not completely recommend with out
>>> understanding your complete environment.
>>> 
>>> Regards,
>>> Ravi.
>>> 
>>> 
>>> himadri wrote:
>>>> 
>>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> This is strange. The problem comes when I add Child Associations to the
>>>> entity. If I remove Child Asscoiations , all work fine. I have attached
>>>> my Sample here. 
>>>> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
>>>> ear on WL10.3. 
>>>> 
>>>> Let me know if you find out anything .. for now I have replace all
>>>> em.find with em.createQuery(Select ...) , But will like to know the
>>>> real reason behind it ! 
>>>> 
>>>> Lemme know if I can provide more simplified sample ....
>>>> 
>>>> Thanks,
>>>> Himadri 
>>>> 
>>>> 
>>>> ________________________________
>>>> From: Kevin Sutter [via OpenJPA]
>>>> <ml...@n2.nabble.com>
>>>> To: himadri <hi...@yahoo.co.in>
>>>> Sent: Thu, 3 December, 2009 5:39:17 AM
>>>> Subject: Re: Open JPA generates incorrect Union All for Date and
>>>> Boolean Datatype
>>>> 
>>>> This sounds very strange.  From your description, I have no idea why
>>>> Date 
>>>> and Boolean attributes are having problems with Oracle.  And, why a
>>>> Union 
>>>> All is being generated for a simple find operation baffles me as well. 
>>>> Unless there is some inheritance or eagerly fetched relationships
>>>> involved. 
>>>> Still, I thought OpenJPA used Joins over Unions. 
>>>> 
>>>> Can you simplify the problem to a simple testcase that could be
>>>> provided? 
>>>> 
>>>> Thanks, 
>>>> Kevin 
>>>> 
>>>> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
>>>> 
>>>> 
>>>>> 
>>>>> Hi, 
>>>>> 
>>>>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g
>>>>> DB. I 
>>>>> have an entity Typed which has Date and Boolean datatypes. em.persist
>>>>> is 
>>>>> sucessful. 
>>>>> 
>>>>> But whereever there is em.find() on any entity in this application , I
>>>>> have 
>>>>> observed that open JPA  tries to get Union  of all entities. This may
>>>>> be 
>>>>> because its first time , But it fails with exception 
>>>>> 
>>>>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>>>>> datatype as corresponding expression" 
>>>>> 
>>>>> The SQL generated is union all of all entities in the application .
>>>>> For 
>>>>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have
>>>>> to_date 
>>>>> function for date. I have used DATE and boolean in Entity class. 
>>>>> 
>>>>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>>>>> '1970-01-01', 
>>>>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>>>>> UNION ALL 
>>>>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>>>>> t0.ENUMED1_F, 
>>>>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM
>>>>> TYPED_T t0 
>>>>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>>>>> state=HY000] 
>>>>> 
>>>>> I guess openJPA fails to add to_date function for DATE and surrounding 
>>>>> chars 
>>>>> for boolean. Is this a bug or some settings available.  Why is it
>>>>> trying to 
>>>>> get union all even for em.find(... ) ? 
>>>>> 
>>>>> Thanks in advance.. 
>>>>> - H 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> View this message in context: 
>>>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>>>>> 
>>>> 
>>>> 
>>>> ________________________________
>>>> 
>>>> View message @
>>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
>>>> To unsubscribe from Open JPA generates incorrect Union All for Date and
>>>> Boolean Datatype, click here. 
>>>> 
>>>> 
>>>> 
>>>>       The INTERNET now has a personality. YOURS! See your Yahoo!
>>>> Homepage. http://in.yahoo.com/
>>>>  
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4149660.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Ravi P Palacherla <ra...@oracle.com>.
Hi Himadri,

Here are answers for some of your questions:

>> Why is it trying to get union all even for em.find(... ) ? 

In your application all the entities ( E.g: AddOn.java, Typed.java) are all
subclasses of EntityBase.

If you use either of the following property:
<property name="openjpa.jdbc.SubclassFetchMode" value="parallel"/>
or
<property name="openjpa.jdbc.SubclassFetchMode" value="none"/>
then you will not see the error.

If you use parallel, then seperate select statements are used to eager fetch
data for subclasses 
and if you use "none" then I guess it will no try to fetch the subclasses.
so, you can use any of the above properties to fix your issue.

The third type of SubclassFetchMode is "join" and even though the
documentation claims that "parallel" is default mode 
http://openjpa.apache.org/builds/1.1.0/apache-openjpa-1.1.0/docs/manual/manual.html#openjpa.jdbc.SubclassFetchMode
The default looks like "join" mode.

So if using any of the above properties is acceptable to you then please use
it.

If you must use "JOIN" then please let me know and I will spend more time to
find the cause of the issue.

Regards,
Ravi.





Himadri wrote:
> 
> So sorry .. attached the wrong one .. Please see the correct one here.If I
> run the junit , I get this exception "javax.ejb.EJBException: EJB
> Exception: ; nested exception is: 
> 	<openjpa-1.1.0-r422266:657916 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
> Driver][Oracle]ORA-01790: expression must have same datatype as
> corresponding expression
>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID =
> ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0,
> NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '',
> '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
> t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
> [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> 	at
> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
> 	at
> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
> 	at $Proxy0.testType(Unknown Source)
> 	at com.tieto.magic.poc.test.TestSample.testP(TestSample.java:54)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at junit.framework.TestCase.runTest(TestCase.java:168)
> 	at junit.framework.TestCase.runBare(TestCase.java:134)
> 	at junit.framework.TestResult$1.protect(TestResult.java:110)
> 	at junit.framework.TestResult.runProtected(TestResult.java:128)
> 	at junit.framework.TestResult.run(TestResult.java:113)
> 	at junit.framework.TestCase.run(TestCase.java:124)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
> 	at junit.framework.TestSuite.run(TestSuite.java:227)
> 	at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> 	at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
> Driver][Oracle]ORA-01790: expression must have same datatype as
> corresponding expression
>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID =
> ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0,
> NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '',
> '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
> t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
> [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
> 	at
> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
> 	at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:268)
> 	at
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> 	at
> org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:336)
> 	at
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> 	at
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> 	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
> 	at kodo.kernel.KodoBroker.initialize(KodoBroker.java:65)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:769)
> 	at kodo.kernel.KodoBroker.find(KodoBroker.java:232)
> 	at
> org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:183)
> 	at
> org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:452)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90)
> 	at
> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)
> 	at
> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
> 	at
> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)
> 	at $Proxy140.find(Unknown Source)
> 	at
> com.tieto.magic.poc.domain.DomainServicesBean.testType(DomainServicesBean.java:48)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
> 	at
> weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
> 	at
> com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
> 	at $Proxy142.testType(Unknown Source)
> 	at
> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl.testType(DomainServicesBean_au5mn8_DomainServicesRImpl.java:65)
> 	at
> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl_WLSkel.invoke(Unknown
> Source)
> 	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
> 	at
> weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
> 	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
> 	at
> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
> 	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
> 	at
> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
> 	at
> weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
> 	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
> 	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
> Caused by: java.lang.Exception:
> org.apache.openjpa.lib.jdbc.ReportingSQLException: [BEA][Oracle JDBC
> Driver][Oracle]ORA-01790: expression must have same datatype as
> corresponding expression
>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID =
> ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0,
> NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '',
> '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
> t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
> [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> 	at
> org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:249)
> 	at
> org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
> 	at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
> 	at
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
> 	at
> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
> 	at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
> 	at
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
> 	at
> weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
> 	at
> weblogic.rjvm.MsgAbbrevOutputStream.sendThrowable(MsgAbbrevOutputStream.java:471)
> 	at
> weblogic.rmi.internal.BasicServerRef.handleThrowable(BasicServerRef.java:694)
> 	at
> weblogic.rmi.internal.BasicServerRef.postInvoke(BasicServerRef.java:650)
> 	at
> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:492)
> 	... 3 more
> 
> "
> 
>  http://n2.nabble.com/file/n4138239/SampleEJBEar.ear SampleEJBEar.ear 
> 
> Ravi P Palacherla wrote:
>> 
>> Looks like the SampleEJB.ear in the attachment is not a correct ear.
>> I am unable to deploy it on Weblogic server.
>> 
>> Also the configuration files (like persistence.xml) and entities are
>> missing in the attachment without which I may not be able to tell what
>> configuration you are using.
>> 
>> Are you using openJPA configurations or kodo configurations ?
>> There was a known issue with a CLOB data type when kodo configuration is
>> used. 
>> The fix for this is in kodo files, it overrides openJPA's classes in
>> order to fix it.
>> 
>> Before going into details of the fix, Please attach a replicable
>> testcase.
>> That way I can see if the same fix applies for your scenario or not.
>> 
>> It would be great if you are able to replicate the issue with openJPA
>> configuration itself; we can work together on resolving the issue in
>> openJPA itself.
>> 
>> Also there were some workarounds of setting
>> "SubclassFetchMode=none";which I would not completely recommend with out
>> understanding your complete environment.
>> 
>> Regards,
>> Ravi.
>> 
>> 
>> himadri wrote:
>>> 
>>> 
>>> 
>>> Hi,
>>> 
>>> This is strange. The problem comes when I add Child Associations to the
>>> entity. If I remove Child Asscoiations , all work fine. I have attached
>>> my Sample here. 
>>> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
>>> ear on WL10.3. 
>>> 
>>> Let me know if you find out anything .. for now I have replace all
>>> em.find with em.createQuery(Select ...) , But will like to know the real
>>> reason behind it ! 
>>> 
>>> Lemme know if I can provide more simplified sample ....
>>> 
>>> Thanks,
>>> Himadri 
>>> 
>>> 
>>> ________________________________
>>> From: Kevin Sutter [via OpenJPA]
>>> <ml...@n2.nabble.com>
>>> To: himadri <hi...@yahoo.co.in>
>>> Sent: Thu, 3 December, 2009 5:39:17 AM
>>> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
>>> Datatype
>>> 
>>> This sounds very strange.  From your description, I have no idea why
>>> Date 
>>> and Boolean attributes are having problems with Oracle.  And, why a
>>> Union 
>>> All is being generated for a simple find operation baffles me as well. 
>>> Unless there is some inheritance or eagerly fetched relationships
>>> involved. 
>>> Still, I thought OpenJPA used Joins over Unions. 
>>> 
>>> Can you simplify the problem to a simple testcase that could be
>>> provided? 
>>> 
>>> Thanks, 
>>> Kevin 
>>> 
>>> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
>>> 
>>> 
>>>> 
>>>> Hi, 
>>>> 
>>>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g
>>>> DB. I 
>>>> have an entity Typed which has Date and Boolean datatypes. em.persist
>>>> is 
>>>> sucessful. 
>>>> 
>>>> But whereever there is em.find() on any entity in this application , I
>>>> have 
>>>> observed that open JPA  tries to get Union  of all entities. This may
>>>> be 
>>>> because its first time , But it fails with exception 
>>>> 
>>>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>>>> datatype as corresponding expression" 
>>>> 
>>>> The SQL generated is union all of all entities in the application . For 
>>>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have
>>>> to_date 
>>>> function for date. I have used DATE and boolean in Entity class. 
>>>> 
>>>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>>>> '1970-01-01', 
>>>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>>>> UNION ALL 
>>>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>>>> t0.ENUMED1_F, 
>>>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM
>>>> TYPED_T t0 
>>>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>>>> state=HY000] 
>>>> 
>>>> I guess openJPA fails to add to_date function for DATE and surrounding 
>>>> chars 
>>>> for boolean. Is this a bug or some settings available.  Why is it
>>>> trying to 
>>>> get union all even for em.find(... ) ? 
>>>> 
>>>> Thanks in advance.. 
>>>> - H 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> View this message in context: 
>>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>>>> 
>>> 
>>> 
>>> ________________________________
>>> 
>>> View message @
>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
>>> To unsubscribe from Open JPA generates incorrect Union All for Date and
>>> Boolean Datatype, click here. 
>>> 
>>> 
>>> 
>>>       The INTERNET now has a personality. YOURS! See your Yahoo!
>>> Homepage. http://in.yahoo.com/
>>>  
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4149434.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Ravi P Palacherla <ra...@oracle.com>.
Hi Himadri,

Can you please add :
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
to your persistence.xml  and see if you are still able to replicate the
issue.

Also it would be great if you can share your client code with me, so I can
replicate the issue.

Regards,
Ravi.
 

Himadri wrote:
> 
> So sorry .. attached the wrong one .. Please see the correct one here.If I
> run the junit , I get this exception "javax.ejb.EJBException: EJB
> Exception: ; nested exception is: 
> 	<openjpa-1.1.0-r422266:657916 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
> Driver][Oracle]ORA-01790: expression must have same datatype as
> corresponding expression
>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID =
> ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0,
> NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '',
> '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
> t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
> [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> 	at
> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
> 	at
> weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
> 	at $Proxy0.testType(Unknown Source)
> 	at com.tieto.magic.poc.test.TestSample.testP(TestSample.java:54)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at junit.framework.TestCase.runTest(TestCase.java:168)
> 	at junit.framework.TestCase.runBare(TestCase.java:134)
> 	at junit.framework.TestResult$1.protect(TestResult.java:110)
> 	at junit.framework.TestResult.runProtected(TestResult.java:128)
> 	at junit.framework.TestResult.run(TestResult.java:113)
> 	at junit.framework.TestCase.run(TestCase.java:124)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:232)
> 	at junit.framework.TestSuite.run(TestSuite.java:227)
> 	at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> 	at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> 	at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
> Driver][Oracle]ORA-01790: expression must have same datatype as
> corresponding expression
>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID =
> ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0,
> NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '',
> '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
> t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
> [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
> 	at
> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
> 	at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
> 	at
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:268)
> 	at
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> 	at
> org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:336)
> 	at
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
> 	at
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
> 	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
> 	at kodo.kernel.KodoBroker.initialize(KodoBroker.java:65)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
> 	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:769)
> 	at kodo.kernel.KodoBroker.find(KodoBroker.java:232)
> 	at
> org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:183)
> 	at
> org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:452)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90)
> 	at
> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)
> 	at
> weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
> 	at
> weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)
> 	at $Proxy140.find(Unknown Source)
> 	at
> com.tieto.magic.poc.domain.DomainServicesBean.testType(DomainServicesBean.java:48)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
> 	at
> weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
> 	at
> com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
> 	at
> com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
> 	at
> com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
> 	at $Proxy142.testType(Unknown Source)
> 	at
> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl.testType(DomainServicesBean_au5mn8_DomainServicesRImpl.java:65)
> 	at
> com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl_WLSkel.invoke(Unknown
> Source)
> 	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
> 	at
> weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
> 	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
> 	at
> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
> 	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
> 	at
> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
> 	at
> weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
> 	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
> 	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
> Caused by: java.lang.Exception:
> org.apache.openjpa.lib.jdbc.ReportingSQLException: [BEA][Oracle JDBC
> Driver][Oracle]ORA-01790: expression must have same datatype as
> corresponding expression
>  {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F,
> '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID =
> ? UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0,
> NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ?
> UNION ALL SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
> t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
> t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
> t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
> SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '',
> '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
> t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
> [params=(String) 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A, (String)
> 34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
> 	at
> org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:249)
> 	at
> org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at
> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
> 	at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
> 	at
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
> 	at
> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
> 	at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
> 	at
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
> 	at
> weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
> 	at
> weblogic.rjvm.MsgAbbrevOutputStream.sendThrowable(MsgAbbrevOutputStream.java:471)
> 	at
> weblogic.rmi.internal.BasicServerRef.handleThrowable(BasicServerRef.java:694)
> 	at
> weblogic.rmi.internal.BasicServerRef.postInvoke(BasicServerRef.java:650)
> 	at
> weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:492)
> 	... 3 more
> 
> "
> 
>  http://n2.nabble.com/file/n4138239/SampleEJBEar.ear SampleEJBEar.ear 
> 
> Ravi P Palacherla wrote:
>> 
>> Looks like the SampleEJB.ear in the attachment is not a correct ear.
>> I am unable to deploy it on Weblogic server.
>> 
>> Also the configuration files (like persistence.xml) and entities are
>> missing in the attachment without which I may not be able to tell what
>> configuration you are using.
>> 
>> Are you using openJPA configurations or kodo configurations ?
>> There was a known issue with a CLOB data type when kodo configuration is
>> used. 
>> The fix for this is in kodo files, it overrides openJPA's classes in
>> order to fix it.
>> 
>> Before going into details of the fix, Please attach a replicable
>> testcase.
>> That way I can see if the same fix applies for your scenario or not.
>> 
>> It would be great if you are able to replicate the issue with openJPA
>> configuration itself; we can work together on resolving the issue in
>> openJPA itself.
>> 
>> Also there were some workarounds of setting
>> "SubclassFetchMode=none";which I would not completely recommend with out
>> understanding your complete environment.
>> 
>> Regards,
>> Ravi.
>> 
>> 
>> himadri wrote:
>>> 
>>> 
>>> 
>>> Hi,
>>> 
>>> This is strange. The problem comes when I add Child Associations to the
>>> entity. If I remove Child Asscoiations , all work fine. I have attached
>>> my Sample here. 
>>> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
>>> ear on WL10.3. 
>>> 
>>> Let me know if you find out anything .. for now I have replace all
>>> em.find with em.createQuery(Select ...) , But will like to know the real
>>> reason behind it ! 
>>> 
>>> Lemme know if I can provide more simplified sample ....
>>> 
>>> Thanks,
>>> Himadri 
>>> 
>>> 
>>> ________________________________
>>> From: Kevin Sutter [via OpenJPA]
>>> <ml...@n2.nabble.com>
>>> To: himadri <hi...@yahoo.co.in>
>>> Sent: Thu, 3 December, 2009 5:39:17 AM
>>> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
>>> Datatype
>>> 
>>> This sounds very strange.  From your description, I have no idea why
>>> Date 
>>> and Boolean attributes are having problems with Oracle.  And, why a
>>> Union 
>>> All is being generated for a simple find operation baffles me as well. 
>>> Unless there is some inheritance or eagerly fetched relationships
>>> involved. 
>>> Still, I thought OpenJPA used Joins over Unions. 
>>> 
>>> Can you simplify the problem to a simple testcase that could be
>>> provided? 
>>> 
>>> Thanks, 
>>> Kevin 
>>> 
>>> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
>>> 
>>> 
>>>> 
>>>> Hi, 
>>>> 
>>>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g
>>>> DB. I 
>>>> have an entity Typed which has Date and Boolean datatypes. em.persist
>>>> is 
>>>> sucessful. 
>>>> 
>>>> But whereever there is em.find() on any entity in this application , I
>>>> have 
>>>> observed that open JPA  tries to get Union  of all entities. This may
>>>> be 
>>>> because its first time , But it fails with exception 
>>>> 
>>>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>>>> datatype as corresponding expression" 
>>>> 
>>>> The SQL generated is union all of all entities in the application . For 
>>>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have
>>>> to_date 
>>>> function for date. I have used DATE and boolean in Entity class. 
>>>> 
>>>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>>>> '1970-01-01', 
>>>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>>>> UNION ALL 
>>>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>>>> t0.ENUMED1_F, 
>>>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM
>>>> TYPED_T t0 
>>>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>>>> state=HY000] 
>>>> 
>>>> I guess openJPA fails to add to_date function for DATE and surrounding 
>>>> chars 
>>>> for boolean. Is this a bug or some settings available.  Why is it
>>>> trying to 
>>>> get union all even for em.find(... ) ? 
>>>> 
>>>> Thanks in advance.. 
>>>> - H 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> View this message in context: 
>>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>>>> 
>>> 
>>> 
>>> ________________________________
>>> 
>>> View message @
>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
>>> To unsubscribe from Open JPA generates incorrect Union All for Date and
>>> Boolean Datatype, click here. 
>>> 
>>> 
>>> 
>>>       The INTERNET now has a personality. YOURS! See your Yahoo!
>>> Homepage. http://in.yahoo.com/
>>>  
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4148425.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by himadri <hi...@yahoo.co.in>.
So sorry .. attached the wrong one .. Please see the correct one here.If I
run the junit , I get this exception "javax.ejb.EJBException: EJB Exception:
; nested exception is: 
	<openjpa-1.1.0-r422266:657916 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
Driver][Oracle]ORA-01790: expression must have same datatype as
corresponding expression
 {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F, '',
0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ?
UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0, NULL,
'', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ? UNION ALL
SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '', '',
'', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
[params=(String) 34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A, (String) 34B85860E33211DE984DF2390A53043A,
(String) 34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
	at
weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:105)
	at
weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:87)
	at $Proxy0.testType(Unknown Source)
	at com.tieto.magic.poc.test.TestSample.testP(TestSample.java:54)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: [BEA][Oracle JDBC
Driver][Oracle]ORA-01790: expression must have same datatype as
corresponding expression
 {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F, '',
0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ?
UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0, NULL,
'', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ? UNION ALL
SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '', '',
'', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
[params=(String) 34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A, (String) 34B85860E33211DE984DF2390A53043A,
(String) 34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
	at org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:268)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
	at
org.apache.openjpa.datacache.DataCacheStoreManager.initialize(DataCacheStoreManager.java:336)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:111)
	at
org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
	at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:894)
	at kodo.kernel.KodoBroker.initialize(KodoBroker.java:65)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:852)
	at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:769)
	at kodo.kernel.KodoBroker.find(KodoBroker.java:232)
	at
org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:183)
	at
org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:452)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:90)
	at
weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)
	at
weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)
	at
weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)
	at $Proxy140.find(Unknown Source)
	at
com.tieto.magic.poc.domain.DomainServicesBean.testType(DomainServicesBean.java:48)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
	at
com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
	at
com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
	at
com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
	at
com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
	at
com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
	at
com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
	at
weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
	at
com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
	at
com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
	at
com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at
com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
	at
com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
	at
com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
	at
com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
	at
com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
	at $Proxy142.testType(Unknown Source)
	at
com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl.testType(DomainServicesBean_au5mn8_DomainServicesRImpl.java:65)
	at
com.tieto.magic.poc.domain.DomainServicesBean_au5mn8_DomainServicesRImpl_WLSkel.invoke(Unknown
Source)
	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
	at
weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
	at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
	at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
	at
weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.Exception:
org.apache.openjpa.lib.jdbc.ReportingSQLException: [BEA][Oracle JDBC
Driver][Oracle]ORA-01790: expression must have same datatype as
corresponding expression
 {prepstmnt 2625 SELECT 0, t0.ID, t0.version, t0.master_Ref, t0.NAME_F, '',
0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ?
UNION ALL SELECT 1, t0.ID, t0.version, t0.addOn_Ref, t0.NAME_F, '', 0, NULL,
'', 0, 0, '1970-01-01', '', 0.0 FROM Master_T t0 WHERE t0.ID = ? UNION ALL
SELECT 2, t0.ID, t0.version, t0.NAME_F, t0.primaryMaster_Ref,
t0.secondaryMaster_Ref, 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
Slave_T t0 WHERE t0.ID = ? UNION ALL SELECT 3, t0.ID, t0.version,
t0.addOn_Ref, t0.NAME_F, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
SubAddOn_T t0 WHERE t0.ID = ? UNION ALL SELECT 4, t0.ID, t0.version,
t0.NAME_F, t0.slave_Ref, '', 0, NULL, '', 0, 0, '1970-01-01', '', 0.0 FROM
SubSlave_T t0 WHERE t0.ID = ? UNION ALL SELECT 5, t0.ID, t0.version, '', '',
'', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, t0.ENUMED2_F, t0.FLAG_F,
t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 WHERE t0.ID = ?
[params=(String) 34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A, (String) 34B85860E33211DE984DF2390A53043A,
(String) 34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A, (String)
34B85860E33211DE984DF2390A53043A]} [code=1790, state=HY000]
	at
org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:249)
	at
org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
	at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
	at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
	at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
	at
weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
	at
weblogic.rjvm.MsgAbbrevOutputStream.sendThrowable(MsgAbbrevOutputStream.java:471)
	at
weblogic.rmi.internal.BasicServerRef.handleThrowable(BasicServerRef.java:694)
	at weblogic.rmi.internal.BasicServerRef.postInvoke(BasicServerRef.java:650)
	at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:492)
	... 3 more

"

http://n2.nabble.com/file/n4138239/SampleEJBEar.ear SampleEJBEar.ear 

Ravi P Palacherla wrote:
> 
> Looks like the SampleEJB.ear in the attachment is not a correct ear.
> I am unable to deploy it on Weblogic server.
> 
> Also the configuration files (like persistence.xml) and entities are
> missing in the attachment without which I may not be able to tell what
> configuration you are using.
> 
> Are you using openJPA configurations or kodo configurations ?
> There was a known issue with a CLOB data type when kodo configuration is
> used. 
> The fix for this is in kodo files, it overrides openJPA's classes in order
> to fix it.
> 
> Before going into details of the fix, Please attach a replicable testcase.
> That way I can see if the same fix applies for your scenario or not.
> 
> It would be great if you are able to replicate the issue with openJPA
> configuration itself; we can work together on resolving the issue in
> openJPA itself.
> 
> Also there were some workarounds of setting "SubclassFetchMode=none";which
> I would not completely recommend with out understanding your complete
> environment.
> 
> Regards,
> Ravi.
> 
> 
> himadri wrote:
>> 
>> 
>> 
>> Hi,
>> 
>> This is strange. The problem comes when I add Child Associations to the
>> entity. If I remove Child Asscoiations , all work fine. I have attached
>> my Sample here. 
>> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
>> ear on WL10.3. 
>> 
>> Let me know if you find out anything .. for now I have replace all
>> em.find with em.createQuery(Select ...) , But will like to know the real
>> reason behind it ! 
>> 
>> Lemme know if I can provide more simplified sample ....
>> 
>> Thanks,
>> Himadri 
>> 
>> 
>> ________________________________
>> From: Kevin Sutter [via OpenJPA]
>> <ml...@n2.nabble.com>
>> To: himadri <hi...@yahoo.co.in>
>> Sent: Thu, 3 December, 2009 5:39:17 AM
>> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
>> Datatype
>> 
>> This sounds very strange.  From your description, I have no idea why Date 
>> and Boolean attributes are having problems with Oracle.  And, why a Union 
>> All is being generated for a simple find operation baffles me as well. 
>> Unless there is some inheritance or eagerly fetched relationships
>> involved. 
>> Still, I thought OpenJPA used Joins over Unions. 
>> 
>> Can you simplify the problem to a simple testcase that could be provided? 
>> 
>> Thanks, 
>> Kevin 
>> 
>> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
>> 
>> 
>>> 
>>> Hi, 
>>> 
>>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g
>>> DB. I 
>>> have an entity Typed which has Date and Boolean datatypes. em.persist is 
>>> sucessful. 
>>> 
>>> But whereever there is em.find() on any entity in this application , I
>>> have 
>>> observed that open JPA  tries to get Union  of all entities. This may be 
>>> because its first time , But it fails with exception 
>>> 
>>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>>> datatype as corresponding expression" 
>>> 
>>> The SQL generated is union all of all entities in the application . For 
>>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date 
>>> function for date. I have used DATE and boolean in Entity class. 
>>> 
>>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>>> '1970-01-01', 
>>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>>> UNION ALL 
>>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>>> t0.ENUMED1_F, 
>>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T
>>> t0 
>>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>>> state=HY000] 
>>> 
>>> I guess openJPA fails to add to_date function for DATE and surrounding 
>>> chars 
>>> for boolean. Is this a bug or some settings available.  Why is it trying
>>> to 
>>> get union all even for em.find(... ) ? 
>>> 
>>> Thanks in advance.. 
>>> - H 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> View this message in context: 
>>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>>> 
>> 
>> 
>> ________________________________
>> 
>> View message @
>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
>> To unsubscribe from Open JPA generates incorrect Union All for Date and
>> Boolean Datatype, click here. 
>> 
>> 
>> 
>>       The INTERNET now has a personality. YOURS! See your Yahoo!
>> Homepage. http://in.yahoo.com/
>>  
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4138239.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Ravi P Palacherla <ra...@oracle.com>.
Looks like the SampleEJB.ear in the attachment is not a correct ear.
I am unable to deploy it on Weblogic server.

Also the configuration files (like persistence.xml) and entities are missing
in the attachment without which I may not be able to tell what configuration
you are using.

Are you using openJPA configurations or kodo configurations ?
There was a known issue with a CLOB data type when kodo configuration is
used. 
The fix for this is in kodo files, it overrides openJPA's classes in order
to fix it.

Before going into details of the fix, Please attach a replicable testcase.
That way I can see if the same fix applies for your scenario or not.

It would be great if you are able to replicate the issue with openJPA
configuration itself; we can work together on resolving the issue in openJPA
itself.

Also there were some workarounds of setting "SubclassFetchMode=none";which I
would not completely recommend with out understanding your complete
environment.

Regards,
Ravi.


himadri wrote:
> 
> 
> 
> Hi,
> 
> This is strange. The problem comes when I add Child Associations to the
> entity. If I remove Child Asscoiations , all work fine. I have attached my
> Sample here. 
> Please see JPG for Entity Associations. SampleEJB.ear is the deployable
> ear on WL10.3. 
> 
> Let me know if you find out anything .. for now I have replace all em.find
> with em.createQuery(Select ...) , But will like to know the real reason
> behind it ! 
> 
> Lemme know if I can provide more simplified sample ....
> 
> Thanks,
> Himadri 
> 
> 
> ________________________________
> From: Kevin Sutter [via OpenJPA]
> <ml...@n2.nabble.com>
> To: himadri <hi...@yahoo.co.in>
> Sent: Thu, 3 December, 2009 5:39:17 AM
> Subject: Re: Open JPA generates incorrect Union All for Date and Boolean
> Datatype
> 
> This sounds very strange.  From your description, I have no idea why Date 
> and Boolean attributes are having problems with Oracle.  And, why a Union 
> All is being generated for a simple find operation baffles me as well. 
> Unless there is some inheritance or eagerly fetched relationships
> involved. 
> Still, I thought OpenJPA used Joins over Unions. 
> 
> Can you simplify the problem to a simple testcase that could be provided? 
> 
> Thanks, 
> Kevin 
> 
> On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 
> 
> 
>> 
>> Hi, 
>> 
>> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB.
>> I 
>> have an entity Typed which has Date and Boolean datatypes. em.persist is 
>> sucessful. 
>> 
>> But whereever there is em.find() on any entity in this application , I
>> have 
>> observed that open JPA  tries to get Union  of all entities. This may be 
>> because its first time , But it fails with exception 
>> 
>> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
>> datatype as corresponding expression" 
>> 
>> The SQL generated is union all of all entities in the application . For 
>> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date 
>> function for date. I have used DATE and boolean in Entity class. 
>> 
>> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
>> '1970-01-01', 
>> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
>> UNION ALL 
>> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F,
>> t0.ENUMED1_F, 
>> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T
>> t0 
>> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790,
>> state=HY000] 
>> 
>> I guess openJPA fails to add to_date function for DATE and surrounding 
>> chars 
>> for boolean. Is this a bug or some settings available.  Why is it trying
>> to 
>> get union all even for em.find(... ) ? 
>> 
>> Thanks in advance.. 
>> - H 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> View this message in context: 
>> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
>> 
> 
> 
> ________________________________
> 
> View message @
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
> To unsubscribe from Open JPA generates incorrect Union All for Date and
> Boolean Datatype, click here. 
> 
> 
> 
>       The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/
>  
> 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4130072.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by himadri <hi...@yahoo.co.in>.


Hi,

This is strange. The problem comes when I add Child Associations to the entity. If I remove Child Asscoiations , all work fine. I have attached my Sample here. 
Please see JPG for Entity Associations. SampleEJB.ear is the deployable ear on WL10.3. 

Let me know if you find out anything .. for now I have replace all em.find with em.createQuery(Select ...) , But will like to know the real reason behind it ! 

Lemme know if I can provide more simplified sample ....

Thanks,
Himadri 


________________________________
From: Kevin Sutter [via OpenJPA] <ml...@n2.nabble.com>
To: himadri <hi...@yahoo.co.in>
Sent: Thu, 3 December, 2009 5:39:17 AM
Subject: Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

This sounds very strange.  From your description, I have no idea why Date 
and Boolean attributes are having problems with Oracle.  And, why a Union 
All is being generated for a simple find operation baffles me as well. 
Unless there is some inheritance or eagerly fetched relationships involved. 
Still, I thought OpenJPA used Joins over Unions. 

Can you simplify the problem to a simple testcase that could be provided? 

Thanks, 
Kevin 

On Tue, Dec 1, 2009 at 7:15 AM, himadri <[hidden email]> wrote: 


> 
> Hi, 
> 
> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB. I 
> have an entity Typed which has Date and Boolean datatypes. em.persist is 
> sucessful. 
> 
> But whereever there is em.find() on any entity in this application , I have 
> observed that open JPA  tries to get Union  of all entities. This may be 
> because its first time , But it fails with exception 
> 
> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same 
> datatype as corresponding expression" 
> 
> The SQL generated is union all of all entities in the application . For 
> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date 
> function for date. I have used DATE and boolean in Entity class. 
> 
> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0, 
> '1970-01-01', 
> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ? 
> UNION ALL 
> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F, 
> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0 
> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790, state=HY000] 
> 
> I guess openJPA fails to add to_date function for DATE and surrounding 
> chars 
> for boolean. Is this a bug or some settings available.  Why is it trying to 
> get union all even for em.find(... ) ? 
> 
> Thanks in advance.. 
> - H 
> 
> 
> 
> 
> 
> 
> -- 
> View this message in context: 
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com. 
> 


________________________________

View message @ http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4103283.html 
To unsubscribe from Open JPA generates incorrect Union All for Date and Boolean Datatype, click here. 



      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
 
-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4126266.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Kevin Sutter <kw...@gmail.com>.
This sounds very strange.  From your description, I have no idea why Date
and Boolean attributes are having problems with Oracle.  And, why a Union
All is being generated for a simple find operation baffles me as well.
Unless there is some inheritance or eagerly fetched relationships involved.
Still, I thought OpenJPA used Joins over Unions.

Can you simplify the problem to a simple testcase that could be provided?

Thanks,
Kevin

On Tue, Dec 1, 2009 at 7:15 AM, himadri <hi...@yahoo.co.in> wrote:

>
> Hi,
>
> I have an EJB3.0 application deployed on Weblogic 10.3 and Oracle 10g DB. I
> have an entity Typed which has Date and Boolean datatypes. em.persist is
> sucessful.
>
> But whereever there is em.find() on any entity in this application , I have
> observed that open JPA  tries to get Union  of all entities. This may be
> because its first time , But it fails with exception
>
> "[BEA][Oracle JDBC Driver][Oracle]ORA-01790:expression must have same
> datatype as corresponding expression"
>
> The SQL generated is union all of all entities in the application . For
> boolean FLAG_F , MOMENT_F wrong sql is generated. It should have to_date
> function for date. I have used DATE and boolean in Entity class.
>
> SELECT 0, t0.ID, t0.version, t0.NAME_F, '', 0, NULL, '', 0, 0,
> '1970-01-01',
> '', 0.0 FROM AddOn_T t0 WHERE t0.ID = ?
> UNION ALL
> SELECT 1, t0.ID, t0.version, '', '', t0.COUNTER_F, t0.DATA_F, t0.ENUMED1_F,
> t0.ENUMED2_F, t0.FLAG_F, t0.MOMENT_F, t0.NAME_F, t0.VALUE_F FROM TYPED_T t0
> WHERE t0.ID = ? [params=(String) 30, (String) 30]} [code=1790, state=HY000]
>
> I guess openJPA fails to add to_date function for DATE and surrounding
> chars
> for boolean. Is this a bug or some settings available.  Why is it trying to
> get union all even for em.find(... ) ?
>
> Thanks in advance..
> - H
>
>
>
>
>
>
> --
> View this message in context:
> http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4093559.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

RE: Open JPA generates incorrect Union All for Date and Boolean Datatype

Posted by Himadri <hi...@yahoo.co.in>.
Well thanks for your opinion .. 

Id is the primary key which is a String not Long or int (Obviously with
millions of records , i wouldnt want to have primary key within boundary of
long or int ) and all tables of my application has the same kind of id
column ...Isnt it better and more clear than having long for one , int for
another and string for rest ? So far I havent come across any such
application .. What is the case when we would want such a scenerio ? 


But I still donot get the idea that Entity should not be part of inheritance
hierarchy ! Infact with 3.0 specification , entity should behave like any
other object model and support all kind of OOPS fundamentals ! 

<Such cases include many-to-many linking tables 
and subordinate tables with a foreign key reference back to their parent 
table. >
With my limited knowledge of associations .. I didnt get the issue clearly
here .. What will be the issue with mapping table/ref column since all
primary keys are of same kind .. ? What could go wrong ghastly ..? Could you
elaborte here ?


 

-- 
View this message in context: http://n2.nabble.com/Open-JPA-generates-incorrect-Union-All-for-Date-and-Boolean-Datatype-tp4093559p4426171.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.