mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
#2326 - [ddl generator] Primary key constraint not generated for @IdClass
This commit is contained in:
1 parent
b22791c15b
commit
09cb5da3d3
5 files changed
+180
-1
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package org.tests.model.compositekeys;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Embeddable
|
||||
public class CKEmbId {
|
||||
|
||||
private UUID siteId;
|
||||
private UUID userId;
|
||||
|
||||
public CKEmbId(UUID siteId, UUID userId) {
|
||||
this.siteId = siteId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UUID getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "st:" + siteId + " ui:" + userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CKEmbId that = (CKEmbId) o;
|
||||
return Objects.equals(siteId, that.siteId) && Objects.equals(userId, that.userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(siteId, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Just simulating the hash from Objects.hash(...)
|
||||
*/
|
||||
int otherHash() {
|
||||
int result = 31 + siteId.hashCode();
|
||||
result = 31 * result + userId.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.tests.model.compositekeys;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.Version;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@IdClass(CKEmbId.class)
|
||||
public class CKSiteUser {
|
||||
|
||||
@Id
|
||||
private UUID siteId;
|
||||
|
||||
@Id
|
||||
private UUID userId;
|
||||
|
||||
private String accessLevel;
|
||||
|
||||
@Version
|
||||
private long version;
|
||||
|
||||
public CKSiteUser(String accessLevel, UUID siteId, UUID userId) {
|
||||
this.accessLevel = accessLevel;
|
||||
this.siteId = siteId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UUID getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(UUID siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user