Reputation: 1015
I have an Entity builded according this pattern :
@Entity
@Table(name = "participation_formation")
public class ParticipationFormation extends Model {
@Id
public int id;
@OneToOne
@JoinColumn(name = "id_formation")
public Formation formation;
@OneToOne
@JoinColumn(name = "id_adp")
public AssistantDePrevention assistantDePrevention;
@Column(name = "a_participe")
public boolean aParticipe;
@Column(name = "commentaire_participation")
public String commentaireParticipation;
@OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REFRESH })
@Column(name = "formation_remplacement")
public ParticipationFormation formationRemplacement;
}
I try to make a query like this :
public static List<ParticipationFormation> search(JsonNode node) {
ExpressionList<ParticipationFormation> query = ParticipationFormation.find.where();
if (node.has("aParticipe"))
query.eq("aParticipe", node.get("aParticipe").asBoolean());
if (node.has("formation"))
query.eq("formation", Formation.extract(node.get("formation")));
if (node.has("assistantDePrevention"))
query.eq("assistantDePrevention", AssistantDePrevention.extract(node.get("assistantDePrevention")));
return query.findList();
}
The extract()
methods have a special logic for retrieving or creating beans from a Json Node.
In my case, node have only a "assistantDePrevention" field.
When findList()
is reached, I have this Exception (I shortened the output) :
PersistenceException: Query threw new SQLException: Unknown column 't0.formation_remplacement_id' in 'field list'
When I remove the cascading informations, it works.
Someone have a solution to my problem, or an explanation ?
Upvotes: 1
Views: 34
Reputation: 24403
Change @Column
to @JoinColumn
in formationRemplacement
mapping.
Upvotes: 1