I have 3 Entity beans:

@Entity(name = "User")
@Table(name = "APP_USERS")
public class User {
    private Integer userId;
    private String userName;
    @Id
    @Column(name = "USER_ID", nullable = false, length = 22)
    public Integer getUserId() {
        return userId;
    }

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

    @Basic
    @Column(name = "USER_NAME", length = 25)
    public String getName() {
        return userName;
    }

    private List<Access> accs;

    @OneToMany(mappedBy = "user")
    public List<Access> getAccs(){
        return accs;
    }
    public void setAccs(List<Access> accs) {
        this.accs = accs;
    }
}

@Entity(name = "Application")
@Table(name = "WEB_APP")
public class Application implements java.io.Serializable {
    private Integer appId;
    private String appName;

    @Id
    @Column(name = "APP_ID", nullable = false, length = 22)
    public Integer getAppId() {
        return appId;
    }

    public void setAppId(Integer appId) {
        this.appId = appId;
    }

    @Basic
    @Column(name = "APP_NAME", nullable = false, length = 100)
    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

}

@Entity(name = "Access")
@Table(name = "APP_ACCESS")
public class Access implements Serializable {

   private User user;
   private AccessPK id;

    public Access(){

    }

    public Access(Integer userId, Integer appId){
        this.id = new AccessPK(userId, appId);
    }


   @EmbeddedId
   @AttributeOverrides({
         @AttributeOverride(name = "userId", column = @Column(name =
"user_id")),
         @AttributeOverride(name = "appId", column = @Column(name="app_id"))
       })
    public AccessPK getId(){
        return this.id;
    }
    public void setId(AccessPK id){
        this.id=id;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "USER_ID")
    public User getUser(){
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}

@Embeddable
public class AccessPK implements Serializable {
    @Column(name = "USER_ID")
    private Integer userId;
    @Column(name = "APP_ID")
    private Integer appId;

    public AccessPK() {
    }

    public AccessPK(Integer userId, Integer appId) {
        this.userId = userId;
        this.appId = appId;
    }

    public boolean equals(Object o) {
        if (o instanceof AccessPK) {
            AccessPK that = (AccessPK) o;
            return this.userId.equals(that.userId) &&
                    this.appId.equals(that.appId);
        } else {
            return false;
        }
    }

    public int hashCode() {
        return userId.hashCode() + appId.hashCode();
    }

    public String toString(){
        return "User id: " + this.userId + ", Application id: " + this.appId
;
    }
}

When i try execute user.getAccs() i get SQLException ORA-00936: Missing
Expression.

logs:
[2007-10-03 18:08:04.525] jdbc/bscs.1.48:prepareStatement(select ,
c.user_idfrom APP_USERS o, APP_ACCESS c where (
c.user_id = o.USER_ID) and (o.USER_ID = ?),type=1003,concurrency=1007)
[2007-10-03 18:08:04.526] jdbc/bscs.1.48:clearParameters()
[2007-10-03 18:08:04.526] jdbc/bscs.1.48:setInt(1,8595)
[2007-10-03 18:08:04.526] jdbc/bscs.1.48:executeQuery(select ,
c.user_idfrom APP_USERS o, APP_ACCESS c where (
c.user_id = o.USER_ID) and (o.USER_ID = ?))
[2007-10-03 18:08:04.536] jdbc/bscs.1.48:exn-executeQuery(
java.sql.SQLException: ORA-00936: Missing Expression

What wrong i'm doing? :)

Thanks

-------------------------------
Sergey Plehov
_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to