here is my entity class-
import java.io.Serializable;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import javax.persistence.Column;
@Entity
//@Table(name="Car")
//@IdClass(CarPK.class)
public class Car implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private
String horn;
private String id;
private String steering;
private String chasis;
public Car(){
}
public Car(String horn, String steering, String chasis){
this.horn = horn;
this.steering = steering;
this.chasis = chasis;
}
public Car(String horn){
this.horn = horn;
}
@EmbeddedId
protected CarPK carPK;
@Embedded
protected CarAddress carAddress;
}
Mine CarPK class
import java.io.Serializable;
import javax.persistence.Embeddable;
@Embeddable
public class CarPK //implements Serializable
{
private static final long serialVersionUID = 1L;
private String horn;
private String id;
private String steering;
private String chasis;
public CarPK(){}
public boolean equals(Object other){
System.out.println(" equals method is called");
if (other instanceof CarPK){
final CarPK carPK = (CarPK)other;
return (carPK.equals(chasis) && carPK.equals(horn) && carPK.equals(steering) && carPK.equals(id));
}
else {
return false;
}
}
public int hashCode(){
return super.hashCode();
}
}
and when i try to execute my client code, it gives me exception like this in database-
[#|2008-11-16T15:52:11.753-0500|WARNING|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/Sun1/AppServer/domains/domain1/applications/j2ee-modules/text_ejb_simple1/-actionBazaar.transaction|_ThreadID=31;_ThreadName=p: thread-pool-1; w: 28;_RequestID=2894dd00-ac90-4936-8b6e-a2fd7c3f93b9;|
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Column name 'ID' appears more than once times in the column list of an INSERT statement.
Error Code: -1
Call: INSERT INTO CAR (STEERING, CHASIS, ID, HORN, ID, STEERING, CHASIS, HORN, CITY, STATE, STREETLINE2, ZIPCODE, STREETLINE1, COUNTRY) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [null, null, null, black steerings, null, null, null, black steerings, null, null, null, null, null, null]
Query: InsertObjectQuery(Car@29e202)
please let me know what i am doing wrong...