How to Manage Entity relatinships with hibernate in Google App engine

177 Views Asked by At

When I am having only 1 onetoMany relation code works fine. When I declare more that 1 @onetomany relation in an entity its breaks saying : org.hibernate.exception.SQLGrammarException: Unknown column 'userregist0_.jdoDetachedState' in 'field list' How this can be managed MY entity class is: package com.bullbeardevice.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the user_registration database table.
 * 
 */
@Entity
@Table(name = "user_registration")
@NamedQuery(name = "UserRegistration.findAll", query = "SELECT u FROM UserRegistration u")
@PersistenceCapable(identityType=IdentityType.APPLICATION, detachable="false")
public class UserRegistration implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_Registration_Id")
    private String userRegistrationId;

    @Column(name = "account_Status")
    private int accountStatus;

    @Column(name = "created_By")
    private String createdBy;

    @Column(name = "created_On")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdOn;

    @Column(name = "email_Address")
    private String emailAddress;

    @Column(name = "expiry_Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date expiryDate;

    @ManyToOne
    @JoinColumn(name = "Group_Master_Id")
    private GroupMaster groupMaster;

    @Column(name = "modified_By")
    private String modifiedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "modified_On")
    private Date modifiedOn;

    @Column(name = "user_password")
    private String password;

    @Column(name = "permissions")
    private int permissions;

    // bi-directional many-to-one association to Chat
    @OneToMany(mappedBy = "userRegistration")
    private List<Chat> chats;

    // bi-directional many-to-one association to Coupon
    @OneToMany(mappedBy = "userRegistration")
    private List<Coupon> coupons;

    // bi-directional many-to-one association to DeviceDetail
    @OneToMany(mappedBy = "userRegistration")
    private List<DeviceDetail> deviceDetails;

    // bi-directional many-to-one association to Portfolio
    @OneToMany(mappedBy = "userRegistration")
    private List<Portfolio> portfolios;

    // bi-directional many-to-one association to UserDetail
    @OneToMany(mappedBy = "userRegistration")
    private List<UserDetail> userDetails;

    // bi-directional many-to-one association to UserLoginDetail
    @OneToMany(mappedBy = "userRegistration")
    private List<UserLoginDetail> userLoginDetails;

    // bi-directional many-to-one association to UserRoleMaster
    @ManyToOne
    @JoinColumn(name = "User_Role_Master_Id")
    private UserRoleMaster userRoleMaster;

    // bi-directional many-to-one association to Watch
    @OneToMany(mappedBy = "userRegistration")
    private List<Watch> watches;


    public UserRegistration() {
    }

    /**
     * @return the userRegistrationId
     */
    public String getUserRegistrationId() {
        return userRegistrationId;
    }

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

    /**
     * @return the accountStatus
     */
    public int getAccountStatus() {
        return accountStatus;
    }

    /**
     * @param accountStatus
     *            the accountStatus to set
     */
    public void setAccountStatus(int accountStatus) {
        this.accountStatus = accountStatus;
    }

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

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

    /**
     * @return the createdOn
     */
    public Date getCreatedOn() {
        return createdOn;
    }

    /**
     * @param createdOn
     *            the createdOn to set
     */
    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    /**
     * @return the emailAddress
     */
    public String getEmailAddress() {
        return emailAddress;
    }

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

    /**
     * @return the expiryDate
     */
    public Date getExpiryDate() {
        return expiryDate;
    }

    /**
     * @param expiryDate
     *            the expiryDate to set
     */
    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    /**
     * @return the groupMaster
     */
    public GroupMaster getGroupMaster() {
        return groupMaster;
    }

    /**
     * @param groupMaster
     *            the groupMaster to set
     */
    public void setGroupMaster(GroupMaster groupMaster) {
        this.groupMaster = groupMaster;
    }

    /**
     * @return the modifiedBy
     */
    public String getModifiedBy() {
        return modifiedBy;
    }

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

    /**
     * @return the modifiedOn
     */
    public Date getModifiedOn() {
        return modifiedOn;
    }

    /**
     * @param modifiedOn
     *            the modifiedOn to set
     */
    public void setModifiedOn(Date modifiedOn) {
        this.modifiedOn = modifiedOn;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

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

    /**
     * @return the permissions
     */
    public int getPermissions() {
        return permissions;
    }

    /**
     * @param permissions
     *            the permissions to set
     */
    public void setPermissions(int permissions) {
        this.permissions = permissions;
    }

    /**
     * @return the chats
     */
    public List<Chat> getChats() {
        return chats;
    }

    /**
     * @param chats
     *            the chats to set
     */
    public void setChats(List<Chat> chats) {
        this.chats = chats;
    }

    public Chat addChat(Chat chat) {
        getChats().add(chat);
        chat.setUserRegistration(this);

        return chat;
    }

    public Chat removeChat(Chat chat) {
        getChats().remove(chat);
        chat.setUserRegistration(null);

        return chat;
    }

    public List<Coupon> getCoupons() {
        return this.coupons;
    }

    public void setCoupons(List<Coupon> coupons) {
        this.coupons = coupons;
    }

    public Coupon addCoupon(Coupon coupon) {
        getCoupons().add(coupon);
        coupon.setUserRegistration(this);

        return coupon;
    }

    public Coupon removeCoupon(Coupon coupon) {
        getCoupons().remove(coupon);
        coupon.setUserRegistration(null);

        return coupon;
    }

    public List<DeviceDetail> getDeviceDetails() {
        return this.deviceDetails;
    }

    public void setDeviceDetails(List<DeviceDetail> deviceDetails) {
        this.deviceDetails = deviceDetails;
    }

    public DeviceDetail addDeviceDetail(DeviceDetail deviceDetail) {
        getDeviceDetails().add(deviceDetail);
        deviceDetail.setUserRegistration(this);

        return deviceDetail;
    }

    public DeviceDetail removeDeviceDetail(DeviceDetail deviceDetail) {
        getDeviceDetails().remove(deviceDetail);
        deviceDetail.setUserRegistration(null);

        return deviceDetail;
    }

    public List<Portfolio> getPortfolios() {
        return this.portfolios;
    }

    public void setPortfolios(List<Portfolio> portfolios) {
        this.portfolios = portfolios;
    }

    public Portfolio addPortfolio(Portfolio portfolio) {
        getPortfolios().add(portfolio);
        portfolio.setUserRegistration(this);

        return portfolio;
    }

    public Portfolio removePortfolio(Portfolio portfolio) {
        getPortfolios().remove(portfolio);
        portfolio.setUserRegistration(null);

        return portfolio;
    }

    public List<UserDetail> getUserDetails() {
        return this.userDetails;
    }

    public void setUserDetails(List<UserDetail> userDetails) {
        this.userDetails = userDetails;
    }

    public UserDetail addUserDetail(UserDetail userDetail) {
        getUserDetails().add(userDetail);
        userDetail.setUserRegistration(this);

        return userDetail;
    }

    public UserDetail removeUserDetail(UserDetail userDetail) {
        getUserDetails().remove(userDetail);
        userDetail.setUserRegistration(null);

        return userDetail;
    }

    public List<UserLoginDetail> getUserLoginDetails() {
        return this.userLoginDetails;
    }

    public void setUserLoginDetails(List<UserLoginDetail> userLoginDetails) {
        this.userLoginDetails = userLoginDetails;
    }

    public UserLoginDetail addUserLoginDetail(UserLoginDetail userLoginDetail) {
        getUserLoginDetails().add(userLoginDetail);
        userLoginDetail.setUserRegistration(this);

        return userLoginDetail;
    }

    public UserLoginDetail removeUserLoginDetail(UserLoginDetail userLoginDetail) {
        getUserLoginDetails().remove(userLoginDetail);
        userLoginDetail.setUserRegistration(null);

        return userLoginDetail;
    }

    public UserRoleMaster getUserRoleMaster() {
        return this.userRoleMaster;
    }

    public void setUserRoleMaster(UserRoleMaster userRoleMaster) {
        this.userRoleMaster = userRoleMaster;
    }

    public List<Watch> getWatches() {
        return this.watches;
    }

    public void setWatches(List<Watch> watches) {
        this.watches = watches;
    }

    public Watch addWatch(Watch watch) {
        getWatches().add(watch);
        watch.setUserRegistration(this);

        return watch;
    }

    public Watch removeWatch(Watch watch) {
        getWatches().remove(watch);
        watch.setUserRegistration(null);

        return watch;
    }

}       

Please help. Thanks in advance!

1

There are 1 best solutions below

0
On

With app-engine, you don't need hibernate. Most JPA annotations that you use with hibernate, are natively supported in app-engine. I believe you should not be mixing JDO (javax.jdo) and JPA(javax.persistence).