Re: Oracle XMLType fetch problems

2011-03-25 Thread Michael Dick
The columnDefinition is the way I'd recommend if you know you'll be using
Oracle. Other databases might have a different type names for XML columns so
you're losing a little portability with this approach.

At any rate, I'm glad it worked for you.

-mike


On Fri, Mar 25, 2011 at 3:14 PM, kostellodon wrote:

> I don't have control over our production environment, so I can't ensure
> we'll have the fixpacks available, so I can't try your second solution.
>  But, your first method worked like a charm.  Adding the same
> columnDefinition to my jaxb example caused that to start working also.  The
> restriction seems to be that if I have multiple mappings for the same table,
> the first entity that I use to access the table has to have that
> columnDefinition (which is covered, obviously, by adding that definition to
> all of my entities accessing that table).  Thanks for the help.
>
> Don
>
> 
> From: Michael Dick [via OpenJPA] [mailto:
> ml-node+6208737-1681935879-321...@n2.nabble.com]
> Sent: Friday, March 25, 2011 1:30 PM
> To: Kostello, Donald G [GCG-NAOT]
> Subject: Re: Oracle XMLType fetch problems
>
> Hi Don,
>
> I'm not familiar with jaxb, but what you have looks pretty close to the
> example in the OpenJPA manual.
>
> I've tried to reproduce the non-jaxb path and found that the problem is
> that
> OpenJPA is expecting your XML column to be a VARCHAR (because that's how
> it's defined in the entity).
>
> I've found two ways to solve the problem :
> 1. Add a columnDefinition to your @Column annotation. For example :
>
>@Column(name = "XMLCOLUMN", columnDefinition ="XMLCOLUMN XMLType")
>private String xmlColumn;
>
> 2. Set the openjpa.jdbc.SchemaFactory property to "native" in
> persistence.xml. This will tell OpenJPA to read the column definitions for
> every entity in your persistence unit - so it'll take a little longer to
> create the EntityManagerFactory. You will also want the fixes for
> OPENJPA-128 9 and
> OPENJPA-1874 . These
> are
> available in our nightly snapshots which are picked up by WebSphere on a
> regular basis (but you might need the latest fixpack).
>
> Hope this helps,
> -mike
>
> On Fri, Mar 25, 2011 at 11:47 AM, kostellodon <[hidden
> email]>wrote:
>
> > I am working with base WebSphere 7, which includes JPA 1.2.1, and am
> > interacting with an Oracle 11.2 database.  I have a table with an XMLType
> > column in it that I am trying to persist and later retrieve from.  I am
> > doing my testing using JUnit 4, using ojdbc6.11.1.0.7.0.jar for my
> driver.
> > My classes are being enhanced at loadtime using the javaagent.
> >
> > I have tried 2 different methods to store and retrieve the xmltype
> column.
> > My first class uses a simple String attribute, and looks like this
> > (BasicEntity just contains versioning and user info):
> >
> > @Entity
> > @Table(name="SERVICE_SNAPSHOTS")
> > public class ServiceSnapshot extends BasicEntity {
> >
> >private static final long serialVersionUID = 5789621189247103676L;
> >
> >@Id
> >@Column(name="SS_ID")
> >@SequenceGenerator(name="id_generatorServiceSnapshot",
> > sequenceName="SERVICE_SNAPSHOTS_SEQ", allocationSize=1)
> >@GeneratedValue(strategy=GenerationType.SEQUENCE,
> > generator="id_generatorServiceSnapshot")
> >private Long id;
> >
> >@Column(name="SS_SERVICE_CD")
> >private String serviceCode;
> >
> >@Column(name="SS_OPERATION_CD")
> >private String operationCode;
> >
> >@Column(name="SS_CONTENTS_XML")
> >private String contentsXML;
> >
> >
> > When I persist the objects, things appear to be stored in the database as
> > expected.  If I store and fetch the objects in the same method (so that
> the
> > objects are in the entity manager), everything comes back fine.  I can
> > query
> > the database via SQL and the results are returned.  However, if I just
> > fetch
> > the objects, all of the attributes except the XML attribute are properly
> > fetched.  The XML attribute is null.  If I log the SQL that's being run,
> I
> > see the column in the SQL string, but the contentsXML is still null.
> >
> > My second uses a JAX-B enhanced object to replace the contentsXML
> > attribute,
> > and this attribute looks like this:
> >@Persistent(fetch=FetchType.EAGER)
> >@Strategy("org.apache.openjpa.jdbc.meta.strats.XMLValueHandler")
> >@Column(name="ss_contents_xml")
> >private DEServiceResults results;
> >
> > I get the same behavior with this class - the results attribute is null,
> > even though the other attributes are not, and results is in the SQL query
> > that gets logged.
> >
> > I can fetch the xml if I use a native query, so I don't think it's a
> driver
> > issue.  Am I setting up my xmltype incorrectly, is this an OpenJPA
> problem,
> > or is this a bug with the IBM 

RE: Oracle XMLType fetch problems

2011-03-25 Thread kostellodon
I don't have control over our production environment, so I can't ensure we'll 
have the fixpacks available, so I can't try your second solution.  But, your 
first method worked like a charm.  Adding the same columnDefinition to my jaxb 
example caused that to start working also.  The restriction seems to be that if 
I have multiple mappings for the same table, the first entity that I use to 
access the table has to have that columnDefinition (which is covered, 
obviously, by adding that definition to all of my entities accessing that 
table).  Thanks for the help.

Don


From: Michael Dick [via OpenJPA] 
[mailto:ml-node+6208737-1681935879-321...@n2.nabble.com]
Sent: Friday, March 25, 2011 1:30 PM
To: Kostello, Donald G [GCG-NAOT]
Subject: Re: Oracle XMLType fetch problems

Hi Don,

I'm not familiar with jaxb, but what you have looks pretty close to the
example in the OpenJPA manual.

I've tried to reproduce the non-jaxb path and found that the problem is that
OpenJPA is expecting your XML column to be a VARCHAR (because that's how
it's defined in the entity).

I've found two ways to solve the problem :
1. Add a columnDefinition to your @Column annotation. For example :

@Column(name = "XMLCOLUMN", columnDefinition ="XMLCOLUMN XMLType")
private String xmlColumn;

2. Set the openjpa.jdbc.SchemaFactory property to "native" in
persistence.xml. This will tell OpenJPA to read the column definitions for
every entity in your persistence unit - so it'll take a little longer to
create the EntityManagerFactory. You will also want the fixes for
OPENJPA-128 9 and
OPENJPA-1874 . These are
available in our nightly snapshots which are picked up by WebSphere on a
regular basis (but you might need the latest fixpack).

Hope this helps,
-mike

On Fri, Mar 25, 2011 at 11:47 AM, kostellodon <[hidden 
email]>wrote:

> I am working with base WebSphere 7, which includes JPA 1.2.1, and am
> interacting with an Oracle 11.2 database.  I have a table with an XMLType
> column in it that I am trying to persist and later retrieve from.  I am
> doing my testing using JUnit 4, using ojdbc6.11.1.0.7.0.jar for my driver.
> My classes are being enhanced at loadtime using the javaagent.
>
> I have tried 2 different methods to store and retrieve the xmltype column.
> My first class uses a simple String attribute, and looks like this
> (BasicEntity just contains versioning and user info):
>
> @Entity
> @Table(name="SERVICE_SNAPSHOTS")
> public class ServiceSnapshot extends BasicEntity {
>
>private static final long serialVersionUID = 5789621189247103676L;
>
>@Id
>@Column(name="SS_ID")
>@SequenceGenerator(name="id_generatorServiceSnapshot",
> sequenceName="SERVICE_SNAPSHOTS_SEQ", allocationSize=1)
>@GeneratedValue(strategy=GenerationType.SEQUENCE,
> generator="id_generatorServiceSnapshot")
>private Long id;
>
>@Column(name="SS_SERVICE_CD")
>private String serviceCode;
>
>@Column(name="SS_OPERATION_CD")
>private String operationCode;
>
>@Column(name="SS_CONTENTS_XML")
>private String contentsXML;
>
>
> When I persist the objects, things appear to be stored in the database as
> expected.  If I store and fetch the objects in the same method (so that the
> objects are in the entity manager), everything comes back fine.  I can
> query
> the database via SQL and the results are returned.  However, if I just
> fetch
> the objects, all of the attributes except the XML attribute are properly
> fetched.  The XML attribute is null.  If I log the SQL that's being run, I
> see the column in the SQL string, but the contentsXML is still null.
>
> My second uses a JAX-B enhanced object to replace the contentsXML
> attribute,
> and this attribute looks like this:
>@Persistent(fetch=FetchType.EAGER)
>@Strategy("org.apache.openjpa.jdbc.meta.strats.XMLValueHandler")
>@Column(name="ss_contents_xml")
>private DEServiceResults results;
>
> I get the same behavior with this class - the results attribute is null,
> even though the other attributes are not, and results is in the SQL query
> that gets logged.
>
> I can fetch the xml if I use a native query, so I don't think it's a driver
> issue.  Am I setting up my xmltype incorrectly, is this an OpenJPA problem,
> or is this a bug with the IBM version?
>
> Thanks for any help.
>
> Don
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Oracle-XMLType-fetch-problems-tp6208344p6208344.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>



If you reply to this email, your message will be added to the discussion below:
http://openjpa.208410.n2.nabble.com/Oracle-XMLType-fetch-problem

Re: Oracle XMLType fetch problems

2011-03-25 Thread Michael Dick
Hi Don,

I'm not familiar with jaxb, but what you have looks pretty close to the
example in the OpenJPA manual.

I've tried to reproduce the non-jaxb path and found that the problem is that
OpenJPA is expecting your XML column to be a VARCHAR (because that's how
it's defined in the entity).

I've found two ways to solve the problem :
1. Add a columnDefinition to your @Column annotation. For example :

@Column(name = "XMLCOLUMN", columnDefinition ="XMLCOLUMN XMLType")
private String xmlColumn;

2. Set the openjpa.jdbc.SchemaFactory property to "native" in
persistence.xml. This will tell OpenJPA to read the column definitions for
every entity in your persistence unit - so it'll take a little longer to
create the EntityManagerFactory. You will also want the fixes for
OPENJPA-128 9 and
OPENJPA-1874 . These are
available in our nightly snapshots which are picked up by WebSphere on a
regular basis (but you might need the latest fixpack).

Hope this helps,
-mike

On Fri, Mar 25, 2011 at 11:47 AM, kostellodon wrote:

> I am working with base WebSphere 7, which includes JPA 1.2.1, and am
> interacting with an Oracle 11.2 database.  I have a table with an XMLType
> column in it that I am trying to persist and later retrieve from.  I am
> doing my testing using JUnit 4, using ojdbc6.11.1.0.7.0.jar for my driver.
> My classes are being enhanced at loadtime using the javaagent.
>
> I have tried 2 different methods to store and retrieve the xmltype column.
> My first class uses a simple String attribute, and looks like this
> (BasicEntity just contains versioning and user info):
>
> @Entity
> @Table(name="SERVICE_SNAPSHOTS")
> public class ServiceSnapshot extends BasicEntity {
>
>private static final long serialVersionUID = 5789621189247103676L;
>
>@Id
>@Column(name="SS_ID")
>@SequenceGenerator(name="id_generatorServiceSnapshot",
> sequenceName="SERVICE_SNAPSHOTS_SEQ", allocationSize=1)
>@GeneratedValue(strategy=GenerationType.SEQUENCE,
> generator="id_generatorServiceSnapshot")
>private Long id;
>
>@Column(name="SS_SERVICE_CD")
>private String serviceCode;
>
>@Column(name="SS_OPERATION_CD")
>private String operationCode;
>
>@Column(name="SS_CONTENTS_XML")
>private String contentsXML;
>
>
> When I persist the objects, things appear to be stored in the database as
> expected.  If I store and fetch the objects in the same method (so that the
> objects are in the entity manager), everything comes back fine.  I can
> query
> the database via SQL and the results are returned.  However, if I just
> fetch
> the objects, all of the attributes except the XML attribute are properly
> fetched.  The XML attribute is null.  If I log the SQL that's being run, I
> see the column in the SQL string, but the contentsXML is still null.
>
> My second uses a JAX-B enhanced object to replace the contentsXML
> attribute,
> and this attribute looks like this:
>@Persistent(fetch=FetchType.EAGER)
>@Strategy("org.apache.openjpa.jdbc.meta.strats.XMLValueHandler")
>@Column(name="ss_contents_xml")
>private DEServiceResults results;
>
> I get the same behavior with this class - the results attribute is null,
> even though the other attributes are not, and results is in the SQL query
> that gets logged.
>
> I can fetch the xml if I use a native query, so I don't think it's a driver
> issue.  Am I setting up my xmltype incorrectly, is this an OpenJPA problem,
> or is this a bug with the IBM version?
>
> Thanks for any help.
>
> Don
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Oracle-XMLType-fetch-problems-tp6208344p6208344.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>


Oracle XMLType fetch problems

2011-03-25 Thread kostellodon
I am working with base WebSphere 7, which includes JPA 1.2.1, and am
interacting with an Oracle 11.2 database.  I have a table with an XMLType
column in it that I am trying to persist and later retrieve from.  I am
doing my testing using JUnit 4, using ojdbc6.11.1.0.7.0.jar for my driver. 
My classes are being enhanced at loadtime using the javaagent.

I have tried 2 different methods to store and retrieve the xmltype column. 
My first class uses a simple String attribute, and looks like this
(BasicEntity just contains versioning and user info):

@Entity
@Table(name="SERVICE_SNAPSHOTS")
public class ServiceSnapshot extends BasicEntity {

private static final long serialVersionUID = 5789621189247103676L;

@Id
@Column(name="SS_ID")
@SequenceGenerator(name="id_generatorServiceSnapshot",
sequenceName="SERVICE_SNAPSHOTS_SEQ", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="id_generatorServiceSnapshot")
private Long id;

@Column(name="SS_SERVICE_CD")
private String serviceCode;

@Column(name="SS_OPERATION_CD")
private String operationCode;

@Column(name="SS_CONTENTS_XML")
private String contentsXML;


When I persist the objects, things appear to be stored in the database as
expected.  If I store and fetch the objects in the same method (so that the
objects are in the entity manager), everything comes back fine.  I can query
the database via SQL and the results are returned.  However, if I just fetch
the objects, all of the attributes except the XML attribute are properly
fetched.  The XML attribute is null.  If I log the SQL that's being run, I
see the column in the SQL string, but the contentsXML is still null.

My second uses a JAX-B enhanced object to replace the contentsXML attribute,
and this attribute looks like this:
@Persistent(fetch=FetchType.EAGER)
@Strategy("org.apache.openjpa.jdbc.meta.strats.XMLValueHandler")
@Column(name="ss_contents_xml")
private DEServiceResults results;

I get the same behavior with this class - the results attribute is null,
even though the other attributes are not, and results is in the SQL query
that gets logged.

I can fetch the xml if I use a native query, so I don't think it's a driver
issue.  Am I setting up my xmltype incorrectly, is this an OpenJPA problem,
or is this a bug with the IBM version?

Thanks for any help.

Don

--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Oracle-XMLType-fetch-problems-tp6208344p6208344.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: JPQL delete with subquery

2011-03-25 Thread Pinaki Poddar
Oops:
"DELETE m from Movie m where m.files IS NULL"?



-
Pinaki 
--
View this message in context: 
http://openjpa.208410.n2.nabble.com/JPQL-delete-with-subquery-tp6205105p6208343.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: JPQL delete with subquery

2011-03-25 Thread Pinaki Poddar
How about
"SELECT m from Movie m where m.files IS NULL"?

-
Pinaki 
--
View this message in context: 
http://openjpa.208410.n2.nabble.com/JPQL-delete-with-subquery-tp6205105p6208334.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: MetaModel creation with -Aopenjpa.generate=true

2011-03-25 Thread Marc Logemann
great News!

---
regards
Marc Logemann
http://www.logemann.org
http://www.logentis.de




Am 25.03.2011 um 15:56 schrieb Rick Curtis:

> Marc -
> 
> This problem is fixed[1] in the 2.1.x stream and trunk.
> 
> [1] http://issues.apache.org/jira/browse/OPENJPA-1965
> 
> Thanks,
> Rick
> 
> On Thu, Mar 24, 2011 at 12:57 PM, Rick Curtis  wrote:
> 
>>> I have heard it said that "programmatic javac compiler for debugging"
>> means that you have a junit testcase which calls com.sun.tools.javac.Main.
>> 
>> I heard it somehow involved a chicken and some sort of voodoo dance. :)
>> 
>> 
>> On Thu, Mar 24, 2011 at 11:27 AM, Michael Dick 
>> wrote:
>> 
>>> On Thu, Mar 24, 2011 at 10:40 AM, Marc Logemann  wrote:
>>> 
> 
>> you are late.
> Not really. The code was written two years ago, with a programmatic
>>> javac
> compiler for debugging ;)
 
 
 thats not what i meant. I meant in following our discussion on the list
>>> ;-)
 When i am old and skilled i will check again what you mean with
 "programmatic javac compiler for debugging" :-) until that time point, i
 continue doing this poor "implement a copy/pasted processor and write
>>> some
 println statements in there" (c) hrhr.
 
>>> 
>>> I have heard it said that "programmatic javac compiler for debugging"
>>> means
>>> that you have a junit testcase which calls com.sun.tools.javac.Main. That
>>> way you can debug your junit (or your own main method) and step into the
>>> compilation process.
>>> 
>>> -mike
>>> 
>> 
>> 



Re: MetaModel creation with -Aopenjpa.generate=true

2011-03-25 Thread Rick Curtis
Marc -

This problem is fixed[1] in the 2.1.x stream and trunk.

[1] http://issues.apache.org/jira/browse/OPENJPA-1965

Thanks,
Rick

On Thu, Mar 24, 2011 at 12:57 PM, Rick Curtis  wrote:

> > I have heard it said that "programmatic javac compiler for debugging"
> means that you have a junit testcase which calls com.sun.tools.javac.Main.
>
> I heard it somehow involved a chicken and some sort of voodoo dance. :)
>
>
> On Thu, Mar 24, 2011 at 11:27 AM, Michael Dick 
> wrote:
>
>> On Thu, Mar 24, 2011 at 10:40 AM, Marc Logemann  wrote:
>>
>> > >
>> > >> you are late.
>> > > Not really. The code was written two years ago, with a programmatic
>> javac
>> > > compiler for debugging ;)
>> >
>> >
>> > thats not what i meant. I meant in following our discussion on the list
>> ;-)
>> > When i am old and skilled i will check again what you mean with
>> > "programmatic javac compiler for debugging" :-) until that time point, i
>> > continue doing this poor "implement a copy/pasted processor and write
>> some
>> > println statements in there" (c) hrhr.
>> >
>>
>> I have heard it said that "programmatic javac compiler for debugging"
>> means
>> that you have a junit testcase which calls com.sun.tools.javac.Main. That
>> way you can debug your junit (or your own main method) and step into the
>> compilation process.
>>
>> -mike
>>
>
>


Re: How to enable schema log ?

2011-03-25 Thread Jean-Baptiste BRIAUD -- Novlog
It works fine.

Thanks !

On 24 mars 2011, at 17:24, Michael Dick wrote:

> I think this will work
> 
> 
> I suspect it's case sensitive but haven't tried it out.
> 
> -mike
> 
> On Thu, Mar 24, 2011 at 10:55 AM, Jean-Baptiste BRIAUD -- Novlog <
> j-b.bri...@novlog.com> wrote:
> 
>> Hi,
>> 
>> I got this in an error message :
>> Enable the org.apache.openjpa.jdbc.Schema logging category to see messages
>> about schema data.
>> 
>> I can't find what to add in the persistence.xml if it is there something
>> should be added...
>> 
>> I already added the following line but I feel it is something else :
>> 
>> 
>> Is it linked ?
>> 
>> How to enable that schema logging ?
>> 
>> Thanks !
>> 
>>