Hi Forum,
I'm having a issue with one-to-one shared primary key.
I have a UserAccount class like:
Code:
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
}
And UserForumProfile like:
Code:
@GenericGenerator(name = "userForumProfileGenerator", strategy = "foreign", parameters = @Parameter(name = "property", value = "owner"))
public class UserForumProfile implements Serializable {
@Id
@GeneratedValue(generator = "userForumProfileGenerator")
@Column(name = "id")
private Long id;
@OneToOne
@PrimaryKeyJoinColumn
private User owner;
}
I don't want User refer back to UserForumProfile, so it's one way one-to-one.
The problem is:
If I issue query like:
select xxx, xxx, xxx from UserForumProfile ufp_ where ufp_.owner = ?
And assign User object as parameter, I keep getting positional parameter expecting: 1, actual User@xxxxxx
So I debugged into it and find it is passing only 1 parameter, however when it do "verifyParameters(false)" in AbstractQueryImpl, because one-to-one getColumnSpan always return 0, it consider as not match.
This is a bug? Or I defined my one-to-one mapping wrong?
Thanks for looking at it.
Noodle