-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Cascade persisting help !!!!
PostPosted: Thu Sep 06, 2007 9:57 am 
Newbie

Joined: Thu Sep 06, 2007 9:47 am
Posts: 4
hello !!!!

I have 5 entity : Customer, Order, OrderLine, Contact and ReportBinder.

After a long conversation for subscritpion, I persist data concerning the customer and with the cascade, the order and the contact are persist. In the Order there is a Cascade concernig the orderline (the same for contact and ReportBinder) but they are not persisit.


Why ?

_________________
Yohann


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 12:01 pm 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
Your mapping files ?
(and other required data...)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 3:51 am 
Newbie

Joined: Thu Sep 06, 2007 9:47 am
Posts: 4
I haven't got a mapping file, I work with annotation

_________________
Yohann


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 5:58 am 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
then show the annotations...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 6:08 am 
Newbie

Joined: Thu Sep 06, 2007 9:47 am
Posts: 4
The five entity bean :

Customer :
Code:
@Entity
@Name("Customer")
public class Customer implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long customerId;
    private String companyName;
    private String form;
    private String tva;
    private String emailInvoices;       
    @Column(nullable = false)
    private String adress1;   
    private String adress2;   
    @Column(nullable = false)
    private Long postalCode;
    @Column(nullable = false)
    private String city;
    @Column(nullable = false)
    private String country;
    private Long phone;
    @Column(nullable = false)
    private Long fax;
   
    /**
     *Creates the foreign key in relation to the Order table
     */   
    @OneToMany(mappedBy = "customer", cascade = CascadeType.PERSIST)
    private List<Order> orders;
   
    /**
     *Creates the foreign key in relation to the Contact table
     */
    @OneToMany(mappedBy = "customer", cascade = CascadeType.PERSIST)
    private List<Contact> contacts;
   
    /** Creates a new instance of Client */
    public Customer() {
     
   
    }
getters and setters......


Order
Code:
@Entity
@Table(name = "client_order")
public class Order implements Serializable {
   
    public static enum PaymentType {creditcard, transfert, check};

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long orderId;
   
    @Column(nullable = false)
    @Temporal(TemporalType.DATE)
    private Date orderDate;
    @Column(nullable = false)
    @Temporal(TemporalType.DATE)
    private Date endDate;
    @Temporal(TemporalType.DATE)
    private Date paymentDate;
    private Boolean paymentStatus;
    private PaymentType type;

   
    /**
     *Creates the foreign key in relation to the Partner table
     */
    @ManyToOne
    @JoinColumn (name = "partnerId_fk")
    private Partner partner;
   
    /**
     *Creates the foreign key in relation to the Customer table
     */
    @ManyToOne
    @JoinColumn (name = "customerId_fk")
    private Customer customer;
   
    /**
     *This table creates the joint between the purchase order and its lines of order.
     *The primary key of this table is consisted of the two foreign keys.
     */         
    @OneToMany(mappedBy = "order", cascade = CascadeType.PERSIST)
    private List<OrderLine> orderLines;
    /**
     * Creates a new instance of Order
     */
    public Order() {
    }
.....

OrderLine

Code:
@Entity
@Name("OrderLine")
public class OrderLine implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long lineId;
   
    /**
     *Creates the foreign key in relation to the Product table
     */
    @OneToOne
    @JoinColumn (name = "productId_fk", nullable = false)
    private Product product;
   
       
    /**
     *Creates the foreign key in relation to the Contact table
     */
   
    @ManyToOne
    @JoinColumn (name = "orderId")
    private Order order;
   
    @OneToMany(mappedBy = "line",fetch=FetchType.LAZY, cascade = CascadeType.PERSIST)
    private List<Server> servers;
   
    /**
     *Creates the foreign key in relation to the Discount table
     */
    @ManyToOne
    @JoinColumn (name = "discount")
    private Discount discount;
   
       
   
    /** Creates a new instance of OrderLine */
    public OrderLine() {
    }
....

Contact
Code:
@Entity
@Name("Contact")
public class Contact implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long contactId;
   
    @Column(nullable = false)
    private String firstName;
   
    @Column(nullable = false)
    private String lastName;
   

    private Long phone;
   
    private Long otherPhone;
   
    private Long fax;
   
    @Column(nullable = false)
    private String mail;
   
    @Column(nullable = false)
    private String username;
   
    @Column(nullable = false)
    private String password;
   

    private Date notifyStart;
   

    private Date notifyEnd;
   
    private String position;
       
    /**
     *Creates the foreign key in relation to the Customer table
     */
    @ManyToOne
    @JoinColumn (name = "customerId_fk")
    private Customer customer;
   
   
   
    /**
     *Creates the foreign key in relation to the ContactReportBinder table
     */

    @OneToMany(mappedBy = "contact", cascade = CascadeType.PERSIST)
    private List<ContactReportBinder> Binders;
   
     
    /** Creates a new instance of Contact */
    public Contact() {
    }
......

ReportBinder
Code:
@Entity
@Name("ContactReportBinder")
public class ContactReportBinder implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long binderId;
   
    /**
     *Creates the foreign key in relation to the Report table
     */
    @OneToMany(mappedBy = "binder")
    private List<Report> reports;
   
    /**
     *Creates the foreign key in relation to the Contact table
     */
    @ManyToOne
    @JoinColumn (name = "contactId_fk")
    private Contact contact;
   
    /**
     *Creates the foreign key in relation to the OrderLine table
     */
    @OneToOne(cascade=CascadeType.PERSIST)
    @JoinColumn(name = "lineId_fk")
    private OrderLine line;
   
    /** Creates a new instance of ContactReportBinder */
    public ContactReportBinder() {
    }
......

_________________
Yohann


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.