users@glassfish.java.net

RE: entity relation

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Sat, 21 Mar 2009 03:59:38 +0000

hello,

 

 Cas,

 

Your suggestion below works.

 

Thanks

 

eve
 


Date: Thu, 19 Mar 2009 23:10:36 -0300
From: casmeiron_at_gmail.com
To: users_at_glassfish.dev.java.net
Subject: Re: entity relation

Hi,

Try to do something like:

@Entity
@Table(name="ORDERS")
@SequenceGenerator(name=" SQ_ORDERS",sequenceName=" SQ_ORDERS", initialValue=1, allocationSize=1) public class Orderent implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO , generator="SQ_ORDERS" )
    private Long ordID;


On 3/19/09 10:43 PM, "Eve Pokua" <gorgeous65_at_msn.com> wrote:


Hi,
 
everyone,
 
 
please read the following and let me know if I am on the right track.
 
I've entities-
 
Iteams
 
Customer
 
Order
 
Orderline
 
The Orderline breaks down the many-to many relationship for order and Iteams.
Now, I do remember creating the tables before I normalised them, the system would
create an extra table(which I did not specified) for Iteams and Order. So it would
insert the id (s) of Iteams and Order everytime it was created.
 
The Orderline has fields -
 
orderid
itemid
cusid
qauntity.
 
If i move the fields back into Order and create the many-to-many relationship
between Order and Iteams, then the system will many it for me. Is this the
best way to manage an application like this or should I stick to my normalisation
as mentioned above.
 
Also, I would like the DB to generate the id fields automatically, so in my entities,
I've specified as-
 
@Entity
@Table(name="ORDERS")
public class Orderent implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long ordID;
 
 
.....
 
 
But the DB keeps asking for id when i enter new dada. Now, how do I manage a situation
like this?
 
I'd appreciate any suggestions. Thanks
 
eve
 
 



Windows Live Hotmail just got better. Find out more! <http://clk.atdmt.com/UKM/go/134665311/direct/01/>

_________________________________________________________________
Free photo editing software from Windows Live . Try it now!
http://clk.atdmt.com/UKM/go/134665240/direct/01/