環境: JDK 1.6,JEE5 Hibernate的核心3.3.1.GA,Hibernate註解3.4.0.GA DB:Informix的JPA實體 - org.hibernate.TypeMismatchException
使用逆向工程,創造我的堅持從數據庫架構的實體[注:這是在工作模式我不能改變]
獲取例外選擇basic_auth_accounts org.hibernate.TypeMismatchException的列表時:提供了錯誤的類型類ebusiness.weblogic.model的ID。 UserAccounts。預計:類ebusiness.weblogic.model.UserAccountsId,得到了類ebusiness.weblogic.model.BasicAuthAccountsId
兩個basic_auth_accounts和user_accounts具有複合主鍵和一個一對一的關係。 任何線索在這裏做什麼?這是非常重要的,我得到這個工作。在網絡上找不到任何實質性的解決方案,有人說創建一個hibernate已經完成的ID類,有人說沒有一對一的關係。
請幫助我!
/**
* BasicAuthAccounts generated by hbm2java
*/
@Entity
@Table(name = "basic_auth_accounts", schema = "ebusdevt", catalog = "ebusiness_dev", uniqueConstraints = @UniqueConstraint(columnNames = {
"realm_type_id", "realm_qualifier", "account_name" }))
public class BasicAuthAccounts implements java.io.Serializable {
private BasicAuthAccountsId id;
private UserAccounts userAccounts;
private String accountName;
private String hashedPassword;
private boolean passwdChangeReqd;
private String hashMethodId;
private int failedAttemptNo;
private Date failedAttemptDate;
private Date lastAccess;
public BasicAuthAccounts() {
}
public BasicAuthAccounts(UserAccounts userAccounts, String accountName, String hashedPassword,
boolean passwdChangeReqd, String hashMethodId, int failedAttemptNo) {
this.userAccounts = userAccounts;
this.accountName = accountName;
this.hashedPassword = hashedPassword;
this.passwdChangeReqd = passwdChangeReqd;
this.hashMethodId = hashMethodId;
this.failedAttemptNo = failedAttemptNo;
}
public BasicAuthAccounts(UserAccounts userAccounts, String accountName, String hashedPassword,
boolean passwdChangeReqd, String hashMethodId, int failedAttemptNo,
Date failedAttemptDate, Date lastAccess) {
this.userAccounts = userAccounts;
this.accountName = accountName;
this.hashedPassword = hashedPassword;
this.passwdChangeReqd = passwdChangeReqd;
this.hashMethodId = hashMethodId;
this.failedAttemptNo = failedAttemptNo;
this.failedAttemptDate = failedAttemptDate;
this.lastAccess = lastAccess;
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "realmTypeId", column = @Column(name = "realm_type_id", nullable = false, length = 32)),
@AttributeOverride(name = "realmQualifier", column = @Column(name = "realm_qualifier", nullable = false, length = 32)),
@AttributeOverride(name = "accountId", column = @Column(name = "account_id", nullable = false)) })
public BasicAuthAccountsId getId() {
return this.id;
}
public void setId(BasicAuthAccountsId id) {
this.id = id;
}
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
@NotNull
public UserAccounts getUserAccounts() {
return this.userAccounts;
}
public void setUserAccounts(UserAccounts userAccounts) {
this.userAccounts = userAccounts;
}
/**
* BasicAuthAccountsId generated by hbm2java
*/
@Embeddable
public class BasicAuthAccountsId implements java.io.Serializable {
private String realmTypeId;
private String realmQualifier;
private long accountId;
public BasicAuthAccountsId() {
}
public BasicAuthAccountsId(String realmTypeId, String realmQualifier, long accountId) {
this.realmTypeId = realmTypeId;
this.realmQualifier = realmQualifier;
this.accountId = accountId;
}
/**
* UserAccounts generated by hbm2java
*/
@Entity
@Table(name = "user_accounts", schema = "ebusdevt", catalog = "ebusiness_dev")
public class UserAccounts implements java.io.Serializable {
private UserAccountsId id;
private Realms realms;
private UserDetails userDetails;
private Integer accessLevel;
private String status;
private boolean isEdge;
private String role;
private boolean chargesAccess;
private Date createdTimestamp;
private Date lastStatusChangeTimestamp;
private BasicAuthAccounts basicAuthAccounts;
private Set<Sessions> sessionses = new HashSet<Sessions>(0);
private Set<AccountGroups> accountGroupses = new HashSet<AccountGroups>(0);
private Set<UserPrivileges> userPrivilegeses = new HashSet<UserPrivileges>(0);
public UserAccounts() {
}
public UserAccounts(UserAccountsId id, Realms realms, UserDetails userDetails, String status,
boolean isEdge, boolean chargesAccess) {
this.id = id;
this.realms = realms;
this.userDetails = userDetails;
this.status = status;
this.isEdge = isEdge;
this.chargesAccess = chargesAccess;
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "realmTypeId", column = @Column(name = "realm_type_id", nullable = false, length = 32)),
@AttributeOverride(name = "realmQualifier", column = @Column(name = "realm_qualifier", nullable = false, length = 32)),
@AttributeOverride(name = "accountId", column = @Column(name = "account_id", nullable = false)) })
@NotNull
public UserAccountsId getId() {
return this.id;
}
public void setId(UserAccountsId id) {
this.id = id;
}
@OneToOne(fetch = FetchType.LAZY, mappedBy = "userAccounts")
public BasicAuthAccounts getBasicAuthAccounts() {
return this.basicAuthAccounts;
}
public void setBasicAuthAccounts(BasicAuthAccounts basicAuthAccounts) {
this.basicAuthAccounts = basicAuthAccounts;
}
/**
* UserAccountsId generated by hbm2java
*/
@Embeddable
public class UserAccountsId implements java.io.Serializable {
private String realmTypeId;
private String realmQualifier;
private long accountId;
public UserAccountsId() {
}
public UserAccountsId(String realmTypeId, String realmQualifier, long accountId) {
this.realmTypeId = realmTypeId;
this.realmQualifier = realmQualifier;
this.accountId = accountId;
}
@Column(name = "realm_type_id", nullable = false, length = 32)
@NotNull
@Length(max = 32)
public String getRealmTypeId() {
return this.realmTypeId;
}
public void setRealmTypeId(String realmTypeId) {
this.realmTypeId = realmTypeId;
}
@Column(name = "realm_qualifier", nullable = false, length = 32)
@NotNull
@Length(max = 32)
public String getRealmQualifier() {
return this.realmQualifier;
}
public void setRealmQualifier(String realmQualifier) {
this.realmQualifier = realmQualifier;
}
@Column(name = "account_id", nullable = false)
public long getAccountId() {
return this.accountId;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
主要規範類:
你有解決這個問題嗎?我面臨幾乎相同的問題,但在我的情況下更糟糕,因爲這兩個表使用複合鍵中的這些列的不同名稱。我正試圖在兩個實體之間做一個OneToOne關聯。 – trafalmadorian 2011-01-07 04:39:09