Hibernate Join Column only finds field with OneToMany, I need OneToOne

Multi tool use
Multi tool use


Hibernate Join Column only finds field with OneToMany, I need OneToOne



I have a strange issue in that I can map a field on a oneToMany, but the field can't be found in a OneToOne, i.e.



This works


@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "task_id")
public List<Voice> voices = new ArrayList<Voice>();



But this


@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "task_id")
private Voice voice;



Gives me the error:


Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'gametasks0_.task_id' in 'field list'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException (SQLError.java:686)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException (SQLError.java:663)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException (SQLError.java:653)



Any clues on how I can map OneToOne via a Join Column?





Why in second code snippet you are using annotation @OneToMany??
– Garima Gupta
Jul 2 at 5:53









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

TPfOoa7DGw,ynn oQz9mJdOp0E1Hx,S3q 7 lQa H 395abL lNzSTuCjqDpr1l
l5e5 E4O0XiY75

Popular posts from this blog

Rothschild family

Cinema of Italy