未知的mappedBy in:com.omnypay.dao.bo.CloudSvrUser.UserPwdList,引用的属性unknown:java.util.List.user

时间:2014-09-08 11:47:58

标签: java spring hibernate

我的userupdate个人资料中foregin keyuser

这是我的CloudSvrUsersProfile班级

@Entity
@Table(name="CLOUD_SVR_USERS_PROFILE")
@NamedQuery(name="CloudSvrUsersProfile.findAll", query="SELECT c FROM CloudSvrUsersProfile c")
public class CloudSvrUsersProfile implements Serializable {

private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue
    @Column(name="USERS_PROFILE_ID",nullable=false)
    private long usersProfileId;

    @Column(name="ADDRESS_1")
    private String address1;

    @Column(name="ADDRESS_2")
    private String address2;

    @Column(name="ADDRESS_3")
    private String address3;

    @Column(name="EMAIL_ID")
    private String emialId;

    public String getEmialId() {
        return emialId;
    }

    public void setEmialId(String emialId) {
        this.emialId = emialId;
    }

    @Column(name="CREATED_BY")
    private BigDecimal createdBy;

    @Column(name="CREATED_DATE")
    private Timestamp createdDate;


    @Column(name="FIRST_NAME")
    private String firstName;

    @Column(name="LAST_NAME")
    private String lastName;

    @Column(name="STATE")
    private String state;

    @Column(name="STATUS")
    private BigDecimal status;

    @Column(name="ZIP_CODE")
    private Long zipCode;



    @Id
    @Column(name="USER_ID",nullable=false)
    @GeneratedValue(generator="gen")
    @GenericGenerator(name="gen", strategy="foreign", parameters=@Parameter(name="property", value="user"))
    private Long userId;

    @ManyToOne
    @JoinColumn(name="USER_ID",nullable=false)
    private CloudSvrUser user;

    /**
     * @return the usersProfileId
     */
    public long getUsersProfileId() {
        return usersProfileId;
    }

    /**
     * @param usersProfileId the usersProfileId to set
     */
    public void setUsersProfileId(long usersProfileId) {
        this.usersProfileId = usersProfileId;
    }

    /**
     * @return the address1
     */
    public String getAddress1() {
        return address1;
    }

    /**
     * @param address1 the address1 to set
     */
    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    /**
     * @return the address2
     */
    public String getAddress2() {
        return address2;
    }

    /**
     * @param address2 the address2 to set
     */
    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    /**
     * @return the address3
     */
    public String getAddress3() {
        return address3;
    }

    /**
     * @param address3 the address3 to set
     */
    public void setAddress3(String address3) {
        this.address3 = address3;
    }

    /**
     * @return the createdBy
     */
    public BigDecimal getCreatedBy() {
        return createdBy;
    }

    /**
     * @param createdBy the createdBy to set
     */
    public void setCreatedBy(BigDecimal createdBy) {
        this.createdBy = createdBy;
    }

    /**
     * @return the createdDate
     */
    public Timestamp getCreatedDate() {
        return createdDate;
    }

    /**
     * @param createdDate the createdDate to set
     */
    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    /**
     * @return the firstName
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * @param firstName the firstName to set
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * @return the lastName
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * @param lastName the lastName to set
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * @return the state
     */
    public String getState() {
        return state;
    }

    /**
     * @param state the state to set
     */
    public void setState(String state) {
        this.state = state;
    }

    /**
     * @return the status
     */
    public BigDecimal getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(BigDecimal status) {
        this.status = status;
    }

    /**
     * @return the zipCode
     */
    public Long getZipCode() {
        return zipCode;
    }

    /**
     * @param zipCode the zipCode to set
     */
    public void setZipCode(Long zipCode) {
        this.zipCode = zipCode;
    }

    /**
     * @return the user
     */
    public CloudSvrUser getUser() {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(CloudSvrUser user) {
        this.user = user;
    }


    /*@OneToMany(mappedBy="userProfile",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
    private Set<CloudSvrUsersSecQuestion> secQuestionSet; */

    /**
     * @return the user
     */

    /*@OneToMany(mappedBy="userProfile",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
    private Set<CloudSvrUsersSecQuestion> secQuestionSet; */

    /**
     * @return the user
     */

}

我的user课程是

public class CloudSvrUser implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue
    @Column(name="USER_ID")
    private long userId;

    @Column(name="CREATED_BY")
    private BigDecimal createdBy;

    @Column(name="CREATED_DATE")
    private Timestamp createdDate;

    @Column(name="EMAIL_ID")
    private String emailId;

    @Column(name="IMEI_NO")
    private BigDecimal imeiNo;

    @Temporal(TemporalType.DATE)
    @Column(name="LAST_LOGIN_DATE")
    private Date lastLoginDate;

    @Column(name="MERCHANT_INFO_ID")
    private BigDecimal merchantInfoId;

    @Column(name="MODIFIED_BY")
    private BigDecimal modifiedBy;

    @Column(name="MODIFIED_DATE")
    private Timestamp modifiedDate;

    @Column(name="PASS_CODE")
    private String passCode;

    @Column(name="PHONE_NO")
    private BigDecimal phoneNo;

    private BigDecimal status;


    @Column(name="BADLOGINCOUNT")
    private BigDecimal badLoginCount;

    @Column(name="ISLOGIN")
    private String isLogin;

    @Column(name="ISLOCKED")
    private String isLocked;




    /*@OneToOne(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)   
    private CloudSvrUsersProfile usersProfile;*/

    @OneToMany(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
    private List<CloudSvrTxn> txnList;

    @OneToMany(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)    
    private List<CloudSvrCardInfo> cardInfoSet;

    @OneToMany(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)    
    private List<CloudSvrBankInfo> bankInfoSet;

    @OneToMany(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)    
    private List<CloudSvrUsersSecQuestion> listSecQuestion;

    @OneToMany(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)    
    private List<CloudSvrAccount> listAccount;


    @OneToMany(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)    
    private List<CloudSvrUsersProfile> UserInfoList;

    @OneToOne(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL) 
    private List<CloudSvrPasswordsHistory> UserPwdList;





    public CloudSvrUser() {
    }

    public long getUserId() {
        return this.userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public BigDecimal getCreatedBy() {
        return this.createdBy;
    }

    public void setCreatedBy(BigDecimal createdBy) {
        this.createdBy = createdBy;
    }

    public Object getCreatedDate() {
        return this.createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public String getEmailId() {
        return this.emailId;
    }

    public void setEmailId(String emailId) {
        this.emailId = emailId;
    }

    public BigDecimal getImeiNo() {
        return this.imeiNo;
    }

    public void setImeiNo(BigDecimal imeiNo) {
        this.imeiNo = imeiNo;
    }

    public Date getLastLoginDate() {
        return this.lastLoginDate;
    }

    public void setLastLoginDate(Date lastLoginDate) {
        this.lastLoginDate = lastLoginDate;
    }

    public BigDecimal getMerchantInfoId() {
        return this.merchantInfoId;
    }

    public void setMerchantInfoId(BigDecimal merchantInfoId) {
        this.merchantInfoId = merchantInfoId;
    }

    public BigDecimal getModifiedBy() {
        return this.modifiedBy;
    }

    public void setModifiedBy(BigDecimal modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public Object getModifiedDate() {
        return this.modifiedDate;
    }

    public void setModifiedDate(Timestamp modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public String getPassCode() {
        return this.passCode;
    }

    public void setPassCode(String passCode) {
        this.passCode = passCode;
    }

    public BigDecimal getPhoneNo() {
        return this.phoneNo;
    }

    public void setPhoneNo(BigDecimal phoneNo) {
        this.phoneNo = phoneNo;
    }

    public BigDecimal getStatus() {
        return this.status;
    }

    public void setStatus(BigDecimal status) {
        this.status = status;
    }

    /*public CloudSvrUsersProfile getUsersProfile() {
        return usersProfile;
    }

    public void setUsersProfile(CloudSvrUsersProfile usersProfile) {
        this.usersProfile = usersProfile;
    }*/

    public List<CloudSvrTxn> getTxnList() {
        return txnList;
    }

    public void setTxnList(List<CloudSvrTxn> txnList) {
        this.txnList = txnList;
    }

    /**
     * @return the cardInfoSet
     */
    public List<CloudSvrCardInfo> getCardInfoSet() {
        return cardInfoSet;
    }

    /**
     * @param cardInfoSet the cardInfoSet to set
     */
    public void setCardInfoSet(List<CloudSvrCardInfo> cardInfoSet) {
        this.cardInfoSet = cardInfoSet;
    }

    /**
     * @return the bankInfoSet
     */
    public List<CloudSvrBankInfo> getBankInfoSet() {
        return bankInfoSet;
    }

    /**
     * @param bankInfoSet the bankInfoSet to set
     */
    public void setBankInfoSet(List<CloudSvrBankInfo> bankInfoSet) {
        this.bankInfoSet = bankInfoSet;
    }

    /**
     * @return the badLoginCount
     */
    public BigDecimal getBadLoginCount() {
        return badLoginCount;
    }

    /**
     * @param badLoginCount the badLoginCount to set
     */
    public void setBadLoginCount(BigDecimal badLoginCount) {
        this.badLoginCount = badLoginCount;
    }

    /**
     * @return the isLogin
     */
    public String getIsLogin() {
        return isLogin;
    }

    /**
     * @param isLogin the isLogin to set
     */
    public void setIsLogin(String isLogin) {
        this.isLogin = isLogin;
    }

    /**
     * @return the listSecQuestion
     */
    public List<CloudSvrUsersSecQuestion> getListSecQuestion() {
        return listSecQuestion;
    }

    /**
     * @param listSecQuestion the listSecQuestion to set
     */
    public void setListSecQuestion(List<CloudSvrUsersSecQuestion> listSecQuestion) {
        this.listSecQuestion = listSecQuestion;
    }

    /**
     * @return the isLocked
     */
    public String getIsLocked() {
        return isLocked;
    }

    /**
     * @param isLocked the isLocked to set
     */
    public void setIsLocked(String isLocked) {
        this.isLocked = isLocked;
    }

    /**
     * @return the listAccount
     */
    public List<CloudSvrAccount> getListAccount() {
        return listAccount;
    }

    /**
     * @param listAccount the listAccount to set
     */
    public void setListAccount(List<CloudSvrAccount> listAccount) {
        this.listAccount = listAccount;
    }


    public List<CloudSvrUsersProfile> getUserInfoList() {
        return UserInfoList;
    }

    public void setUserInfoList(List<CloudSvrUsersProfile> userInfoList) {
        UserInfoList = userInfoList;
    }


    public List<CloudSvrPasswordsHistory> getUserPwdList() {
        return UserPwdList;
    }

    public void setUserPwdList(List<CloudSvrPasswordsHistory> userPwdList) {
        UserPwdList = userPwdList;
    }

这是我的bean configuration文件

<context:annotation-config/>

    <context:property-placeholder location="file:${propfilepath}/omnypay.properties"/>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>com.omnypay.dao.bo.CloudSvrSecQuesMaster</value>
                <value>com.omnypay.dao.bo.CloudSvrUser</value>
                <value>com.omnypay.dao.bo.CloudSvrUsersProfile</value>
                <value>com.omnypay.dao.bo.CloudSvrUsersSecQuestion</value>
                <value>com.omnypay.dao.bo.CloudSvrTxn</value>
                <value>com.omnypay.dao.bo.CloudSvrCardInfo</value>
                <value>com.omnypay.dao.bo.CloudSvrBankInfo</value>
                <value>com.omnypay.dao.bo.CloudSvrAccount</value>
                <value>com.omnypay.dao.bo.CloudSvrPasswordsHistory</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${jdbc.dialect}</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
        <property name="dataSource" ref="dataSource" />
    </bean>

    <!-- DAO classes -->
     <bean id="secQuestionDao" class="com.omnypay.dao.impl.SecurityQuestionDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean> 

    <bean id="userDao" class="com.omnypay.dao.impl.UserDaoImpl">
    </bean>

</beans>

我收到的错误就像

Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: com.omnypay.dao.bo.CloudSvrUser.UserPwdList, referenced property unknown: java.util.List.user
    at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:129)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324)
    at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 42 more

请帮助

2 个答案:

答案 0 :(得分:0)

您将其映射为@OneToOne,但随后将其声明为List。

如果它是OneToOne,则意味着只有一个CloudSvrPasswordsHistory将与CloudSvrUser关联,因此不应该有List,而只是:

@OneToOne(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL) 
private CloudSvrPasswordsHistory UserPwdList;

否则,如果您需要为每个CloudSvrUser提供多个CloudSvrPasswordsHistory,请保留List并使用OneToMany。

答案 1 :(得分:0)

我认为问题在于您指定了

@OneToOne(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL) 
private List<CloudSvrPasswordsHistory> UserPwdList;

而不是

@OneToMany