A
Anon
Hi,
I'm trying to find a way to write an entity EJB that would have, as a
primary key, a key composed with 2 other keys which are the PK of 2
others EJB.
Example:
2 entities:
- Book <entity EJB><pk=bookId>
- Subscriber <entity EJB><pk=subscriberId>
1 entity:
- Borrow<entity EJB><pk=bookId,subscriberId>
I know that I can write a BorrowPK containing two fields as a primary
key, but this is not what I want to do.
I want the Borrow entity to have 3 fields:
@EJB Book book;
@EJB Subscriber subscriber;
@Temporal Date date;
and the book/subscriber couple would be the primary key.
The interest of all this is to save database space, and execution time
by not creating a useless "BorrowId" which would be the primary key
field. The other interest would be that we'd have a direct access to
the referenced EJB from the Borrow entity. (ie: borrow.getBook() or
borrow.getSubscriber())
Any idea how I can do that ?
I'm trying to find a way to write an entity EJB that would have, as a
primary key, a key composed with 2 other keys which are the PK of 2
others EJB.
Example:
2 entities:
- Book <entity EJB><pk=bookId>
- Subscriber <entity EJB><pk=subscriberId>
1 entity:
- Borrow<entity EJB><pk=bookId,subscriberId>
I know that I can write a BorrowPK containing two fields as a primary
key, but this is not what I want to do.
I want the Borrow entity to have 3 fields:
@EJB Book book;
@EJB Subscriber subscriber;
@Temporal Date date;
and the book/subscriber couple would be the primary key.
The interest of all this is to save database space, and execution time
by not creating a useless "BorrowId" which would be the primary key
field. The other interest would be that we'd have a direct access to
the referenced EJB from the Borrow entity. (ie: borrow.getBook() or
borrow.getSubscriber())
Any idea how I can do that ?