openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pawelzgoda <pawel.niezgoda.s...@gmail.com>
Subject Bug? SQLException from findObject
Date Tue, 25 Nov 2008 19:51:55 GMT

I think I found a bug in OpenJPA (1.2.0..., also tried with 1.3.0):

To reproduce:
PersonEntity (with PersonPK - idClass (name, surname) complex key).
using InheritanceType.JOINED :
ParentEntity extends PersonEntity
ChildEntity extends PersonEntity

ParentEntity -> OneToMany -> ChildEntity.
(having one parent with two children) Execute query:
"select p, c from ParentEntity p, IN(p.children) c"

Excetion occurs:

     [java] 1485 hellojpa TRACE [main] openjpa.jdbc.SQL - <t 15351007, conn
4359463> executing prepstmnt 23916456 SELECT t0.name, t0.surname, t2.name,
t2.surname, t2.DTYPE, t2.theThing, t1.PARENT_NAME, t1.PARENT_SURNAME, t1.toy
FROM ParentEntity t0 INNER JOIN ChildEntity t1 ON t0.name = t1.PARENT_NAME
AND t0.surname = t1.PARENT_SURNAME INNER JOIN PersonEntity t3 ON t0.name =
t3.name AND t0.surname = t3.surname LEFT OUTER JOIN PersonEntity t2 ON
t1.name = t2.name AND t1.surname = t2.surname WHERE t3.DTYPE = ?
[params=(String) ParentEntity]
     [java] 1485 hellojpa TRACE [main] openjpa.jdbc.SQL - <t 15351007, conn
4359463> [0 ms] spent
     [java] Exception in thread "main"
<openjpa-1.3.0-SNAPSHOT-r422266:707655 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: name
     [java] at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4242)
     [java] at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4207)
     [java] at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
     [java] at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
     [java] at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
     [java] at
org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.handleCheckedException(SelectResultObjectProvider.java:155)
     [java] at
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:40)
     [java] at
org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1233)
     [java] at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:995)
     [java] at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
     [java] at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
     [java] at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771)
     [java] at
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517)
     [java] at
org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:257)
     [java] at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:428)
     [java] at hellojpa.Main.main(Main.java:86)
     [java] Caused by: java.sql.SQLException: name
     [java] at
org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.findObject(SelectImpl.java:2510)
     [java] at
org.apache.openjpa.jdbc.sql.ResultSetResult.translate(ResultSetResult.java:492)
     [java] at
org.apache.openjpa.jdbc.sql.AbstractResult.getString(AbstractResult.java:764)
     [java] at
org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy.getPrimaryKeyValue(StringFieldStrategy.java:212)
     [java] at
org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:189)
     [java] at
org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:149)
     [java] at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:966)
     [java] at
org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
     [java] at
org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2397)
     [java] at
org.apache.openjpa.jdbc.kernel.exps.PCPath.load(PCPath.java:696)
     [java] at
org.apache.openjpa.jdbc.kernel.exps.PCPath.load(PCPath.java:684)
     [java] at
org.apache.openjpa.jdbc.kernel.ProjectionResultObjectProvider.getResultObject(ProjectionResultObjectProvider.java:78)
     [java] at
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
     [java] ... 9 more

When using "SingleTable" inheritance, everything works ok.

-----
public class PersonPK implements Serializable{
String name;
String surname;

@Override
public boolean equals(Object arg0) {
return name.equals(name) && surname.equals(surname);
}

@Override
public int hashCode() {
return name.hashCode() * surname.hashCode();
}
}

--------

@Entity
@IdClass (value=PersonPK.class)
public class PersonEntity {
@Id
String name;
@Id
String surname;

String theThing;

public String getTheThing() {
return theThing;
}
public void setTheThing(String theThing) {
this.theThing = theThing;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}


}
---------
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class ChildEntity extends PersonEntity {
String toy;

@ManyToOne
ParentEntity parent = null;

public String getToy() {
return toy;
}

public void setToy(String toy) {
this.toy = toy;
}

public ParentEntity getParent() {
return parent;
}

public void setParent(ParentEntity parent) {
this.parent = parent;
}

@Override
public String toString() {
return "Child->"+name+", "+surname+", "+toy;
}
}

---------

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class ParentEntity extends PersonEntity {
String job = null;

@OneToMany(mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
Collection<ChildEntity> children = new ArrayList<ChildEntity>();

public String getJob() {
return job;
}

public void setJob(String job) {
this.job = job;
}

public Collection<ChildEntity> getChildren() {
return children;
}

public void setChildren(ArrayList<ChildEntity> children) {
this.children = children;
}

public void addChild(ChildEntity child) {
this.children.add(child);
}

@Override
public String toString() {
return "Parent->"+name+", "+surname+", "+job;
}
} 
-- 
View this message in context: http://n2.nabble.com/Bug--SQLException-from-findObject-tp1577945p1577945.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message