You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Eric Charles <er...@apache.org> on 2010/06/21 20:46:08 UTC

OpenJPA usage at Apache James

Hi,

Apache James project uses OpenJPA 2.0.

We've got @OneToMany relations on AbstractJPAMessage [1] to JPAHeader 
[2] (headers attribute) and JPAProperty [3] (properties attribute).
With current config, intermediary tables are created (MESSAGE_HEADER and 
MESSAGE_PROPERTY) but we would like to get rid of these.

a) We tried to use the @OneToMany 'mappedBy' attribute, adding a 
JPAMessage attribute on the JPAHeader and JPAProperty.
The tables are correctly created if we redefine the annotated headers 
and properties attributes on the concrete JPAMessage [4] class.
We had however to define openjpa.InverseManager=true to make it work at 
runtime.

b) When we set the @OneToMany with 'mappedBy' attribute on the 
AbstractJPAMessage (and the JPAMessage on the JPAHeader and 
JPAProperty), the tables are created, but not the FK. At runtime, the 
application generates SQL, but no response seems to come back (no 
exception in the log). It simply hangs.

c) In a) and b) scenario, we need to define an additional JPAMessage 
concrete attribute on JPAHeader and JPAProperty.
This does not allow to define FK to other types, such as the 
JPAStreamingMessage [5].
In this case, the class structure we built does not make much sense.
Would a Custom Mapping help? 
(http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_mapping_custom)

d) If we set @ElementJoinColumn(name="MESSAGE_ID", 
referencedColumnName="ID") on the headers and properties in the 
AbstractJPAMessage, everything works fine.
This also solve problem mentioned in c) because we don't need any 
JPAMessage attributed on JPAHeader and JPAProperty.
However, we try to stick to the standard JPA API without using OpenJPA 
extensions if not necessary.

e) Apart from the above points, are there any standard way to define 
indexes other than org.apache.openjpa.persistence.jdbc.Index ?

We would like to hear your comments on the above.
What do you think we should consider/investigate? Are our 
interpretations correct?

Tks,

Eric

PS: Please reply-to-all so we can follow the thread on James ml.

[1] AbstractJPAMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/AbstractJPAMessage.java?view=log
[2] JPAHeader 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java?view=log
[3] JPAProperty 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java?view=log
[4] JPAMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMessage.java?view=log
[5] JPAStreamingMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/openjpa/JPAStreamingMessage.java?view=log


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: OpenJPA usage at Apache James

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
The "mappedBy" mapping on abstract class should work and the relations need
not be redefined in the concrete subclass.
But a critical bug on MappedSuperclass had been found recently -- which *may
be* impacting the mapping.

1. Which OpenJPA revision being used? 
$ java -jar /path/to/openjpa.jar 
shows the revision number.

2. If the used revision is prior to 952893 (dated June 8,2010), is it
possible to switch to a post-952893 version and see if that resolves the
issue?

3. Can you please post the relevant entity classes (JPAMesaage etc.) for
further analysis?



-----
Pinaki 
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/OpenJPA-usage-at-Apache-James-tp5205652p5214230.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: OpenJPA usage at Apache James

Posted by Eric Charles <er...@apache.org>.
Hi Pinaki,

We use the maven downloaded jar release 422266:935683 from 22-Apr-2010, 
so we don't have the patch  for the MappedSuperClass.
I didn't find a recent 2.0.0-SNAPSHOT on 
http://people.apache.org/maven-snapshot-repository/ nor on 
https://repository.apache.org/index.html.

Will try with 2.1.0-SNAPSHOT.

The entites can be found here:
[1] AbstractJPAMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/AbstractJPAMessage.java?view=markup
[2] JPAHeader 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java?view=markup
[3] JPAProperty 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java?view=markup
[4] JPAMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMessage.java?view=markup
[5] JPAStreamingMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/openjpa/JPAStreamingMessage.java?view=markup 


Tks,

Eric


On 06/23/2010 07:04 PM, Pinaki Poddar wrote:
> Hi,
> The "mappedBy" mapping on abstract class should work and the relations need
> not be redefined in the concrete subclass.
> But a critical bug on MappedSuperclass had been found recently -- which *may
> be* impacting the mapping.
>
> 1. Which OpenJPA revision being used?
> $ java -jar /path/to/openjpa.jar
> shows the revision number.
>
> 2. If the used revision is prior to 952893 (dated June 8,2010), is it
> possible to switch to a post-952893 version and see if that resolves the
> issue?
>
> 3. Can you please post the relevant entity classes (JPAMesaage etc.) for
> further analysis?
>
>
>
> -----
> Pinaki
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: OpenJPA usage at Apache James

Posted by Eric Charles <er...@apache.org>.
Hi Pinaki,

We use the maven downloaded jar release 422266:935683 from 22-Apr-2010, 
so we don't have the patch  for the MappedSuperClass.
I didn't find a recent 2.0.0-SNAPSHOT on 
http://people.apache.org/maven-snapshot-repository/ nor on 
https://repository.apache.org/index.html.

Will try with 2.1.0-SNAPSHOT.

The entites can be found here:
[1] AbstractJPAMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/AbstractJPAMessage.java?view=markup
[2] JPAHeader 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java?view=markup
[3] JPAProperty 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java?view=markup
[4] JPAMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMessage.java?view=markup
[5] JPAStreamingMessage 
http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/openjpa/JPAStreamingMessage.java?view=markup 


Tks,

Eric


On 06/23/2010 07:04 PM, Pinaki Poddar wrote:
> Hi,
> The "mappedBy" mapping on abstract class should work and the relations need
> not be redefined in the concrete subclass.
> But a critical bug on MappedSuperclass had been found recently -- which *may
> be* impacting the mapping.
>
> 1. Which OpenJPA revision being used?
> $ java -jar /path/to/openjpa.jar
> shows the revision number.
>
> 2. If the used revision is prior to 952893 (dated June 8,2010), is it
> possible to switch to a post-952893 version and see if that resolves the
> issue?
>
> 3. Can you please post the relevant entity classes (JPAMesaage etc.) for
> further analysis?
>
>
>
> -----
> Pinaki
>    


Re: OpenJPA usage at Apache James

Posted by Eric Charles <er...@u-mangate.com>.
Hi Pinaki,

OpenJPA 2.1.0-SNAPSHOT didn't help.
I also made a separate sample with a Message, AbstractMessage and Header 
(a message has many headers).
I defined:
- @OneToMany(mappedBy...) with type Header on the AbstractMessage
- @ManyToOne with type AbstractMessage on the Header.
With that config, the FK is not created (nor the corresponding 
message_id column in Header table). I receive no exception.

Another question was the definition of indexes: Does JPA standard 
provide this ?

Tks,

Eric


On 06/24/2010 05:26 AM, Eric Charles wrote:
> Hi Pinaki,
>
> We use the maven downloaded jar release 422266:935683 from 
> 22-Apr-2010, so we don't have the patch  for the MappedSuperClass.
> I didn't find a recent 2.0.0-SNAPSHOT on 
> http://people.apache.org/maven-snapshot-repository/ nor on 
> https://repository.apache.org/index.html.
>
> Will try with 2.1.0-SNAPSHOT.
>
> The entites can be found here:
> [1] AbstractJPAMessage 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/AbstractJPAMessage.java?view=markup 
>
> [2] JPAHeader 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java?view=markup 
>
> [3] JPAProperty 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java?view=markup 
>
> [4] JPAMessage 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMessage.java?view=markup 
>
> [5] JPAStreamingMessage 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/openjpa/JPAStreamingMessage.java?view=markup 
>
>
> Tks,
>
> Eric
>
>
> On 06/23/2010 07:04 PM, Pinaki Poddar wrote:
>> Hi,
>> The "mappedBy" mapping on abstract class should work and the 
>> relations need
>> not be redefined in the concrete subclass.
>> But a critical bug on MappedSuperclass had been found recently -- 
>> which *may
>> be* impacting the mapping.
>>
>> 1. Which OpenJPA revision being used?
>> $ java -jar /path/to/openjpa.jar
>> shows the revision number.
>>
>> 2. If the used revision is prior to 952893 (dated June 8,2010), is it
>> possible to switch to a post-952893 version and see if that resolves the
>> issue?
>>
>> 3. Can you please post the relevant entity classes (JPAMesaage etc.) for
>> further analysis?
>>
>>
>>
>> -----
>> Pinaki
>


Re: OpenJPA usage at Apache James

Posted by Eric Charles <er...@u-mangate.com>.
Hi Pinaki,

OpenJPA 2.1.0-SNAPSHOT didn't help.
I also made a separate sample with a Message, AbstractMessage and Header 
(a message has many headers).
I defined:
- @OneToMany(mappedBy...) with type Header on the AbstractMessage
- @ManyToOne with type AbstractMessage on the Header.
With that config, the FK is not created (nor the corresponding 
message_id column in Header table). I receive no exception.

Another question was the definition of indexes: Does JPA standard 
provide this ?

Tks,

Eric


On 06/24/2010 05:26 AM, Eric Charles wrote:
> Hi Pinaki,
>
> We use the maven downloaded jar release 422266:935683 from 
> 22-Apr-2010, so we don't have the patch  for the MappedSuperClass.
> I didn't find a recent 2.0.0-SNAPSHOT on 
> http://people.apache.org/maven-snapshot-repository/ nor on 
> https://repository.apache.org/index.html.
>
> Will try with 2.1.0-SNAPSHOT.
>
> The entites can be found here:
> [1] AbstractJPAMessage 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/AbstractJPAMessage.java?view=markup 
>
> [2] JPAHeader 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java?view=markup 
>
> [3] JPAProperty 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java?view=markup 
>
> [4] JPAMessage 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAMessage.java?view=markup 
>
> [5] JPAStreamingMessage 
> http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/openjpa/JPAStreamingMessage.java?view=markup 
>
>
> Tks,
>
> Eric
>
>
> On 06/23/2010 07:04 PM, Pinaki Poddar wrote:
>> Hi,
>> The "mappedBy" mapping on abstract class should work and the 
>> relations need
>> not be redefined in the concrete subclass.
>> But a critical bug on MappedSuperclass had been found recently -- 
>> which *may
>> be* impacting the mapping.
>>
>> 1. Which OpenJPA revision being used?
>> $ java -jar /path/to/openjpa.jar
>> shows the revision number.
>>
>> 2. If the used revision is prior to 952893 (dated June 8,2010), is it
>> possible to switch to a post-952893 version and see if that resolves the
>> issue?
>>
>> 3. Can you please post the relevant entity classes (JPAMesaage etc.) for
>> further analysis?
>>
>>
>>
>> -----
>> Pinaki
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org