This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can a class be mapped to a table and be Embeddable at the same time?

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this class called InventoryTransaction... I'm doing this in JPA



Now, I need userId to be changed from an Integer to a InventoryUser object which is already existing and is mapped to a table.



I want my InventoryUser class to be embeddable and at the same time be mapped to a table. Is this possible? Thanks!
[ June 28, 2007: Message edited by: Timothy Sam ]
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like InventoryUser is a separate entity and should be mapped as a one-to-one to your InventoryTransaction entity. It has a PK, named queries and everything, so it isn't an embedded entity at all. I guess I'm not clear on why you want to make it one...

An embedded entity is one that by definition does not have its own identity but depends upon that of its owning entity, and must therefore also be stored in the table of its owning entity.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

In my design, the following should defined as

an inventory transaction has many to one user
a user has one to many transactions

a user has a one to many inventory item
an inventory item has many to 1 user


I just don't know how to incorporate this with my JPA mapping... Have I supplied enough information? Thanks!
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uhmmm... Can I get a help with this?


Caused by: Exception [TOPLINK-7244] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: An incompatible mapping has been encountered between [class com.wp.wpinventory.model.FixedItem] and [class com.wp.wpinventory.model.InventoryTransaction]. This usually occurs when the cardinality of a mapping does not correspond with the cardinality of its backpointer.



Here's what I've been doing...




in FixedItem.java



The mappings were originally generated by netbeans for me. But now that I'm doing everything manually I'm really having problems especially with joins. Thanks!
[ July 03, 2007: Message edited by: Timothy Sam ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic