I put 'mappedBy' at the @OneToMany side(Course) as follows:
Code:
@Entity(access = AccessType.FIELD )
@Inheritance(discriminatorValue="O")
public class Course extends Container {
@Column(name="code")
protected String code;
@OneToMany( cascade = CascadeType.ALL, mappedBy="subscriptions")
@Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
protected Set<Subscription> subscriptions;
and i removed from the mappedBy side(Subscription) the @JoinColumn:
Code:
@Entity(access = AccessType.FIELD)
@Table(name="tsubscriptions")
public class Subscription extends BaseEntity {
@ManyToOne( fetch = FetchType.LAZY )
@JoinColumn( name = "userid", nullable=false)
private User user;
@ManyToOne( fetch = FetchType.LAZY)
//@JoinColumn( name = "courseid", nullable = false, insertable = false, updatable = false)
private Course course;
Unfortunately i have the following sql exception:
Code:
java.sql.SQLException: Invalid column name 'course_id'
Am i doing something wrong?