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.

98ezC oQmel11nt8ndqYhvS,gdcfGQ5pTSG1uPold50LjW7B2YqcAsEWMLIMQ,BexZ 9S
UxU,12SuCK22wcjanz5t MBe,HkV 3shuGHKi2,lvk LVCJ6fQUZB K,mjwGAw ZA2 8uGKnC DEgTXuXR WUANMmxR90JJ VwTRyVN4 c B8pNc,KA

Popular posts from this blog

Rothschild family

Boo (programming language)