Hi,
I’m trying to build my first application using OpenJPA, but I got stuck with an
odd problem.
When declare more than one @ManyToOne relation on one entity, only one
(sometimes none) of them is mapped correctly on the database. I’ve tried with
existing tables and creating the tables by
running the program, but the behavior doesn’t change.
Here is the example I’m trying:
@Entity
public class Project implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private long id;
@Column(nullable = false, length=200)
private String name;
...
}
@Entity
public class Developer implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3366659313976911445L;
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
protected long id;
@Column(nullable = false, length = 200)
private String name;
...
}
@Entity
public class Participation implements Serializable {
/**
*
*/
private static final long serialVersionUID = -5739921124942905231L;
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
protected long id;
@ManyToOne(cascade = CascadeType.ALL)
@ForeignKey
private Project project;
@ManyToOne(cascade = CascadeType.ALL)
@ForeignKey
private Developer developer;
...
}
In Participation either a column referring to Project or one referring to
Developer is created. If I add another @ManyToOne relation, I still get only
the mapping of one column correctly.
I’m using PosgreSQL.
Any ideas of what is happening?
Help me, please.
Lile