2010-05-18 4 views
0

Environnement: JDK 1.6, JEE5 Hibernate Core 3.3.1.GA, Hibernate Annotations 3.4.0.GA DB: Informixentités JPA - org.hibernate.TypeMismatchException

ingénierie inverse utilisés pour créer ma persévérance entités de schéma db [NB: Ceci est un schéma dans le travail je ne peux pas changer]

Obtenir exception lors de la sélection liste des basic_auth_accounts org.hibernate.TypeMismatchException: fourni id du mauvais type pour ebusiness.weblogic.model de classe. Comptes utilisateur. Attendu: classe ebusiness.weblogic.model.UserAccountsId, se classe ebusiness.weblogic.model.BasicAuthAccountsId

Les deux basic_auth_accounts et user_accounts ont les clés primaires composites et un à-un. Des indices quoi faire ici? C'est assez important pour que cela fonctionne. Impossible de trouver une solution substantielle sur le net, certains disent de créer une classe d'identification que Hibernate a fait, et certains disent de ne pas avoir une relation un-à-un.

S'il vous plaît aidez-moi !!

/** 
* 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; 
    } 

Main Code pour les classes sont:

Répondre

0

juste pour donner suite à la recherche/recherche en ligne:

D'après ce que je peux voir que j'ai deux tables basic_auth_accounts et user_accounts qui utilisent les mêmes touches composites realmTypeId , realmQualifier et accountId. Les deux entités ont des classes intégrables avec ces colonnes et des relations un-à-un.

J'ai utilisé des outils hibernate pour générer ces entités à partir du schéma DB que je ne peux pas changer! Je me demande si j'ai utilisé la même classe intégrable pour les deux entités, comme dans renommer BasicAuthAccountsId à un nom plus générique, supprimer UserAccountsId et pour les deux entités utilisent la même classe @EmbeddedId?

+0

Avez-vous résolu ce problème? Je suis confronté à presque le même problème, mais dans mon cas, c'est pire puisque les deux tables utilisent des noms différents pour ces colonnes dans les touches composites. J'essaie de faire une association OneToOne entre les deux entités. – trafalmadorian

Questions connexes