Skip to main content

JPA @OneTOMany ot @OneTOMany with @ManyToOne ??

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
mauro2011
Offline
Joined: 2011-06-08

hi all . Escuse me for my bad English .
I have not understand the difference from the use relationship @OneToMany standalone or @OneToMany with @ManyToOne.

A example:
i have 2 entity:
Customer
Order

! Customer can have many order .

So into the entity Customer i have :

@Entyty
Customer

@Id
Integer id;
String nameCustomer;

@OneTOMany
Set ordersCustomer ;

// other think
.............................................................
@Entity
Order

@Id
Integer id;

String description_product:
Double amount-order;

.................................................

it is not sufficient for use it????

what it is the difference to use also :
-------------------------------------------------------

@Entyty
Customer

@Id
Integer id;
String nameclient;

@OneTOMany (mappedby=customer)
Set ordersCustomert ;

// other think

-------------------------
@Entity
Order

@Id
Integer id;

String descriptionofproduct:
Double amount-order;

Customer customer;

-------------------------------------

Please i ask difference conceptual s and difference int othe geneeration tables into DB .
Tanl you for your attention .
Mauro