You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each user has one account. So the relationship is @OnetoOne and mandatory from user's side.
On the other hand some accounts belong not to users, but to companies. So from the account's side it's @OnetoOne but optional.
I've modeled it in this way:
class User { @OnetoOne(optional = false)
Account account;
}
class Account { @OnetoOne(mappedBy = "account",optional = true)
User user;
}
Generated schema is just what I need (account field in User is NOT NULL).
The problem is that when I'm fetching Account (just with .find(), without additional .fetch() ) ebean makes JOIN of the user, not the LEFT OUTER JOIN although on the account's side the relationship is optional. It only starts making LEFT OUTER JOIN if I make it optional also on user's side. But it this case I'm loosing NOT NULLity of the account_id field.
So the question is: how can I enforce LEFT OUTER JOIN on one side while keeping NOT NULLity on the other side? Adding additional @column(nullable=false) annotation to account field doesn't affect the schema.
The text was updated successfully, but these errors were encountered:
Is there a way to get around this bug in version prior to 4.1.2?? I'm using Play Framework 2.3 and the version of Ebean ORM used is 3.3.4 and I can't change it. I have the exact same problem.
I have two entities: User and Account.
Each user has one account. So the relationship is @OnetoOne and mandatory from user's side.
On the other hand some accounts belong not to users, but to companies. So from the account's side it's @OnetoOne but optional.
I've modeled it in this way:
class User {
@OnetoOne(optional = false)
Account account;
}
class Account {
@OnetoOne(mappedBy = "account",optional = true)
User user;
}
Generated schema is just what I need (account field in User is NOT NULL).
The problem is that when I'm fetching Account (just with .find(), without additional .fetch() ) ebean makes JOIN of the user, not the LEFT OUTER JOIN although on the account's side the relationship is optional. It only starts making LEFT OUTER JOIN if I make it optional also on user's side. But it this case I'm loosing NOT NULLity of the account_id field.
So the question is: how can I enforce LEFT OUTER JOIN on one side while keeping NOT NULLity on the other side? Adding additional @column(nullable=false) annotation to account field doesn't affect the schema.
The text was updated successfully, but these errors were encountered: