Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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 ]
 
author
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 ]
 
I am going to test your electrical conductivity with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic