You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by chintan4181 <ch...@gmail.com> on 2011/06/07 17:59:08 UTC

may be OpenJPA limitation

Hi,

I am using openJPA 2.0 in WAS 7.0. Our application talks with mulitple
persisten unit. One of them is DB2. When i am trying find record using
primary key, i am getting below error.  Data type of primary key of User
entity is BigInt in DB2 and corrosponding java type in entity is long.

<openjpa-2.0.0-r422266:935683 fatal general error>
org.apache.openjpa.persistence.PersistenceException: DB2 SQL Error:
SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DBSCHEMA.USER, DRIVER=4.8.87
{prepstmnt 969619915 SELECT t0.AUDIT_LDAP_DN, t0.AUDIT_TIMESTAMP,
t0.AUDIT_USER, t0.BIRTH_DATE, t0.FIRST_NAME, t0.identifier, t0.LAST_NAME,
t0.STATUS_CODE, t0.TYPE_CODE FROM User t0 WHERE t0.USER_ID = ?  optimize for
1 row [params=(long) 2]} [code=-204, state=42704]SQLCA OUTPUT[Errp=SQLNQ1FC,
Errd=-2145779603, 0, 0, 0, -10, 0]

DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DBSCHEMA.USER,
DRIVER=4.8.87

DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098,
SQLERRMC=2;-204;42704;DBSCHEMA.USER, DRIVER=4.8.87

DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098,
SQLERRMC=2;-204;42704;DBSCHEMA.USER, DRIVER=4.8.87

FailedObject: com.foo.jpa.entities.User-2 [org.apache.openjpa.util.LongId]
[java.lang.String]

      at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4827)

      at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4787)

      at
org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:563)

      at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)

      at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:86)

      at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:347)


If i use Eclipselink persistence provider then it works perfectly. can
anybody help me to resolve this issue?

thanks
chintan

--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6450246.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: may be OpenJPA limitation

Posted by chintan4181 <ch...@gmail.com>.
Here is code snippet

@Entity
@Table(schema="DBSCHEMA")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="USER_ID")
	private long userId;

	@Column(name="AUDIT_LDAP_DN")
	private String auditLdapDn;

	@Column(name="AUDIT_TIMESTAMP")
	private Timestamp auditTimestamp;

	@Column(name="AUDIT_USER")
	private String auditUser;


in my DAO class i am using below code
LOG.info("before find");
			Long key = new Long("2");
			User user = em2.find(User.class, key);
			LOG.info("user last name " + user.getLastName());
			user.setLastName("Jorden");
			em2.merge(user);

persistent.xml has following entry
<persistence-unit name="MIApplicationJPADB2" transaction-type="JTA">
		<description>MIApplication Datasource DB2</description>
		<jta-data-source>jdbc/MIApplicationDSDB2</jta-data-source>
		<class>com.pmigroup.origination.miapplication.jpa.entities.User</class>
		<properties>
			<property name="openjpa.Log" value="SQL=TRACE,JDBC=TRACE" />
		</properties>
	</persistence-unit>

Let me know this much information is fine.

thanks
chintan

--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6459132.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: may be OpenJPA limitation

Posted by Kevin Sutter <kw...@gmail.com>.
Okay, but getting back to Jeremy's comment, the SQLCODE of -240 means that
the referenced item is missing:

SQL0204N "<name>" is an undefined name.

And, <name> from your posted error message is this:  DBSCHEMA.USER

Since the SQL we generated is using the table like this (FROM User t0),
maybe there's an issue with delimited identifiers?  How are you defining
your Entity?  If all by annotations, please post that code snippet.  If you
are also using xml, please post that as well.  Thanks.

Kevin

On Wed, Jun 8, 2011 at 11:56 AM, chintan4181 <ch...@gmail.com> wrote:

> DBSchema exists in DB2 and same code is working fine for EclipseLink
> provider.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6454495.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: may be OpenJPA limitation

Posted by chintan4181 <ch...@gmail.com>.
DBSchema exists in DB2 and same code is working fine for EclipseLink
provider.

--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6454495.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: may be OpenJPA limitation

Posted by Jeremy Bauer <te...@gmail.com>.
Based on the SQLCODE, it looks like the table USER in schema DBSCHEMA
does not exist.  Is that table located in a different schema than the
default?  If so, you have a few options - specify the schema on the
@Table annotation, use the openjpa.jdbc.Schema property, or depending
on the driver and platform, specify a different default schema on the
connection URL[2].  Or, if possible, define the table in DBSSCHEMA.

[1] http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_schema_def.html
[2] http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.java.doc/doc/cjvcfgpr.htm

-Jeremy

On Tue, Jun 7, 2011 at 6:45 PM, Pinaki Poddar <pp...@apache.org> wrote:
> Right now I do not have a computing environment to give you a definite
> answer. But if you do not mind, please try passing a Long (not long).
>
> Why did you think that the application connects to multiple DBs could be
> relevant in this context?
> Given rather straightforward nature of the use case, I am thinking whether
> something else is causing the reported failure.
>
> -----
> Pinaki
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6451867.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: may be OpenJPA limitation

Posted by chintan4181 <ch...@gmail.com>.
I am not saying multiple DB is causing issue. Same this is working fine with
Eclipselink JPA provider. so i believe issue might be with OpenJPA provider.

--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6454153.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: may be OpenJPA limitation

Posted by Pinaki Poddar <pp...@apache.org>.
Right now I do not have a computing environment to give you a definite
answer. But if you do not mind, please try passing a Long (not long). 

Why did you think that the application connects to multiple DBs could be
relevant in this context? 
Given rather straightforward nature of the use case, I am thinking whether
something else is causing the reported failure. 

-----
Pinaki 
--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6451867.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: may be OpenJPA limitation

Posted by chintan4181 <ch...@gmail.com>.
Long key = new Long("2");
User user = em2.find(User.class, key.longValue());

declaration of User entity
@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="USER_ID")
	private long userId;


--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6451381.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: may be OpenJPA limitation

Posted by Pinaki Poddar <pp...@apache.org>.
1. Post the code snippet that calls em.find(...). Especially the argument to
find().
2. The declaration of identity field in User 

-----
Pinaki 
--
View this message in context: http://openjpa.208410.n2.nabble.com/may-be-OpenJPA-limitation-tp6450246p6450263.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.