Hi all

I'm wondering how to do CRUD for the master detail relationship between customer and orders?.
After creating the POJOs and run the following commands, new testcases fail.

mvn test-compile hibernate3:hbm2ddl
mvn appfuse:gen
mvn appfuse:install
mvn jetty:run-war

------------------------ CUSTOMER----------------------
package com.mycompany.app.model;

import org.appfuse.model.BaseObject;
import javax.persistence.*;

import java.util.Collection;

@Entity
public class Customer  extends BaseObject {

   private Long  id;
   private String name;
   private Collection<Orders> orders;

   @Id @GeneratedValue(strategy = GenerationType.AUTO)
   public Long getId() {
                return id;
        }

        public void setId(Long id) {
                this.id = id;
        }
        @Column(name="name", length=50)
   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   @OneToMany(cascade=CascadeType.ALL, mappedBy="customer")
   public Collection<Orders> getOrders() {
       return orders;
   }

   public void setOrders(Collection<Orders> newValue) {
       this.orders = newValue;
   }


        @Override
        public int hashCode() {
                final int PRIME = 31;
                int result = 1;
                result = PRIME * result + ((id == null) ? 0 : id.hashCode());
                result = PRIME * result + ((name == null) ? 0 : 
name.hashCode());
                result = PRIME * result + ((orders == null) ? 0 : 
orders.hashCode());
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                final Customer other = (Customer) obj;
                if (id == null) {
                        if (other.id != null)
                                return false;
                } else if (!id.equals(other.id))
                        return false;
                if (name == null) {
                        if (other.name != null)
                                return false;
                } else if (!name.equals(other.name))
                        return false;
                if (orders == null) {
                        if (other.orders != null)
                                return false;
                } else if (!orders.equals(other.orders))
                        return false;
                return true;
        }

        @Override
        public String toString() {
                // TODO Auto-generated method stub
                return null;
        }



}

--------------------------------------------------- Orders ---------------------------------------

package com.mycompany.app.model;

import org.appfuse.model.BaseObject;
import javax.persistence.*;

@Entity
public class Orders extends BaseObject {

        private Long id;
   private String address;
   private Customer customer;

   @Id @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name="ORDER_ID")
  public Long getId() {
                return id;
        }

        public void setId(Long id) {
                this.id = id;
        }
        @Column(name="SHIPPING_ADDRESS", length=200)
   public String getAddress() {
       return address;
   }

   public void setAddress(String address) {
       this.address = address;
   }

   @ManyToOne()
   @JoinColumn(name="CUSTOMER_ID")
   public Customer getCustomer() {
       return customer;
   }

   public void setCustomer(Customer customer) {
       this.customer = customer;
   }

        @Override
        public int hashCode() {
                final int PRIME = 31;
                int result = 1;
                result = PRIME * result + ((address == null) ? 0 : 
address.hashCode());
                result = PRIME * result + ((customer == null) ? 0 : 
customer.hashCode());
                result = PRIME * result + ((id == null) ? 0 : id.hashCode());
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                final Orders other = (Orders) obj;
                if (address == null) {
                        if (other.address != null)
                                return false;
                } else if (!address.equals(other.address))
                        return false;
                if (customer == null) {
                        if (other.customer != null)
                                return false;
                } else if (!customer.equals(other.customer))
                        return false;
                if (id == null) {
                        if (other.id != null)
                                return false;
                } else if (!id.equals(other.id))
                        return false;
                return true;
        }



        @Override
        public String toString() {
                // TODO Auto-generated method stub
                return null;
        }



}

_________________________________________________________________
Sohbet ve eglence, web kamera ve sesli sohbet Messenger'de. http://messenger.msn.com/?mkt=tr&DI=3490&XAPID=2584

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to