Hi all,
I have two tables, one is 'caller' and other is 'passenger'
relationship is one caller can have many passengers.
in 'caller' table 'caller_id' is the primary key,
in 'passenger' table 'passenger_id' and 'caller_id' are the composite primary key.
'caller_id' is the foreign key of the 'passenger' table.
I did this like this in my classes.
Code:
package com.trn;
@Entity
@Table(name="caller")
public class Caller implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="caller_id")
private int callerId;
@OneToMany(targetEntity=Passenger.class, mappedBy="callerId")
@LazyCollection(LazyCollectionOption.FALSE)
@BatchSize(size = 512)
private List<Passenger> passengers = new ArrayList<Passenger>();
public int getCallerId() {
return callerId;
}
public void setCallerId(int callerId) {
this.callerId = callerId;
}
public void setPassengers(List<Passenger> passengers) {
this.passengers = passengers;
}
public List<Passenger> getPassengers() {
return passengers;
}
}
this is my passenger class
Code:
package com.trn;
@Entity
@Table(name="passenger")
public class Passenger implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="passenger_id")
private int passengerID;
@Column(name="p_caller_id")
private int callerID;
public int getPassengerID() {
return passengerID;
}
public void setPassengerID(int passengerID) {
this.passengerID = passengerID;
}
public int getCallerID() {
return callerID;
}
public void setCallerID(int callerID) {
this.callerID = callerID;
}
}
I have removed All import statements and unwanted getters and setters here.
This code gives me a error like this:
Code:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.trn.Passenger.callerId in com.trn.Caller.passengers
please help me to go through this.....
regards,
DIL.