-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible create an entity class from a table with a composite primary key? #43
Comments
Hi, @jorginius . |
Hi, @Tapac . I commented about the EmbeededId (and Embeddable) annotation because I think it could be the less disruptive approach (one object key, one parameter), but I'm not sure if mimicking JPA is the right way on this point: @Embeddable
public class UserToRoleKey {
@Column(nullable = false)
private String code;
@Column(nullable = false)
private String username;
// ...
}
@Entity
public class UserToRole {
@EmbeddedId
private UserToRoleKey key;
// ...
}
// ...
UserToRoleKey key = new UserToRoleKey();
key.setCode("USER");
key.setUsername("test);
entityManager.find(UserToRole.class, key); "Raw" Table objects can hold a composite key easily: internal object UsersToRoles : Table("users_roles") {
val code = reference("code", Roles.code).primaryKey()
val username = reference("username", Users.username).primaryKey()
} Perhaps the ideal API :-) has a EntityClass which works with Table objects (creating EntityId from primaryId fields automatically) or IdTable is deprecated/superseded by the "vanilla" Table, i don't know. |
It is my only problem in current project! Please lead me with a workaround at least! |
@kamyar1979 , sad, but there is not workaround atm, because entityId is a hardly coupled with a single column instance. We have uncompleted refactoring with this feature support, but it requires a lot of testing before release, so we can't give any ETA :( |
Sorry! I have to return to old Hibernate for now! |
Need this feature as well :( |
Any news? |
A very ugly and <8 bit int-specific work around I've been using:
findByPKs returns the correct object, and accessing these by references in other tables works, I can't say more than that. The shift could be adjusted, and more values could be added. |
seems there is a solution here: #239 |
Have there been any updates on this? |
@Hc747, not yet. |
This issue was created 4 years ago, how is this not fixed yet? |
You should ask for your money back |
I believe that I found a solution: |
@Tapac is there any README about this on-going feature that the community can read and try to contribute? |
Bumping because this is ridicolous, I just made an IntIdTable now without using the Id ever. |
Bump :) |
5 years later we still need it. Really ) |
Bump :) |
bump |
bump! ⏳ |
Bump 🆙 |
Bump |
bump |
1 similar comment
bump |
happy new year |
bump |
1 similar comment
bump |
Merry christmas guys |
@Nek-12 Merry Christmas, any updates? |
Yeah, lots of updates: I finished school, got into university, finished university, started my masters, found a job and left that job. What a great 8 years! |
It seems the API forces the IdTable derived objects have got only one key column. Is there any equivalent to the JPA's EmbeddedId and IdClass annotations?
The text was updated successfully, but these errors were encountered: