openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruslan <rusl...@gmail.com>
Subject Re: AW: How to make compound id via @EmbeddedId
Date Fri, 21 Nov 2008 19:59:35 GMT

That is surprise to me. Thanks a lot for pointing out. I didn't know that
@Embeddable classes have to be registered in persistence.xml because I
thought it's necessary only for entity classes. Perhaps it would be great to
mention it in section "1.4. Embeddable" of the documentation.

Another interesting thing is that I can't register inner class in
persistence.xml like

<class>db.ElectronicBooksDataEntity2.PrimaryKey</class>

Here is example of the class: http://pastebin.ca/1263719

Is it by design or a bug ?

OpenJPA doesn't enhance it. So I had to make PrimaryKey public and move to
upper level. Now it works but only if I use primitives in PrimaryKey. Here
are my classes:

ElectronicBooksDataEntity2: http://pastebin.ca/1263723
PrimaryKey: http://pastebin.ca/1263728

Could you please tell me what I need to modify in PrimaryKey in order to
make PrimaryKey.book an object of ElectronicBooksEntity rather than
numerical int ?

Here is what I tried:

http://pastebin.ca/1263733

I also tried to define @OneToMany relation in ElectronicBooksEntity (even
though I want to have unidirectional relation) as:

    @OneToMany(mappedBy="primaryKey.book", cascade = CascadeType.ALL, fetch
= FetchType.EAGER)
    private List<ElectronicBooksDataEntity2> datas;

but it didn't help either.


PS. There was another person who asked exactly the same question:
http://n2.nabble.com/How-to-make-compound-id-via-%40EmbeddedId-td1559454.html 
but looks like he wasn't able to crack it down either.


Mark Struberg wrote:
> 
> All other classes have been enhanced?
> 
> Let's start with the most obvious: is the <class> PrimaryKey registered in
> your persistence.xml? @Embeddable also have to be registered there.
> 
> LieGrue,
> strub
> 

-- 
View this message in context: http://n2.nabble.com/How-to-make-compound-id-via-%40EmbeddedId-tp1559454p1563278.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message