Hi Rick, That was my first thought as well, but Sanjay does indicate that the records do exist in the database. So, assuming that is correct, there's something else wrong here.
The interesting part is that exception seems to indicate that the id String is null: Exception in thread "main" <openjpa-2.0.1-r422266:989424 nonfatal store error> org.apache.openjpa.persistence.EntityNotFoundException: Cannot perform find using null object id. FailedObject: null [java.lang.String] The code path does an immediate check whether the parameter is null, and we continue processing. So there must be something in the call stack processing that is nulling out the id string. But, this example is so simple, I can't believe that this doesn't work properly. No answer yet... Kevin On Mon, Oct 4, 2010 at 8:13 AM, Rick Curtis <[email protected]> wrote: > Sanjay - > > An org.apache.openjpa.persistence.EntityNotFoundException means that > OpenJPA > couldn't find an Entity with the properties that you provided. I noticed in > your insert section of code the id that you insert is "id2", but you are > searching for "id1". Perhaps that is the problem? > > Thanks, > Rick > > On Sun, Oct 3, 2010 at 2:23 AM, Iron Luca <[email protected]> wrote: > > > Hi All, > > > > I am new to this forum & was thinking is someone could help me out. I > have > > a > > persistent class: > > > > import javax.persistence.Entity; > > import javax.persistence.Id; > > import javax.persistence.Table; > > > > @Entity > > @Table > > public class TestTable { > > > > @Id > > @Column > > protected String id; > > > > @Column > > protected String text; > > > > public String getId() { > > return id; > > } > > > > public void setId(String id) { > > this.id = id; > > } > > > > public String getText() { > > return text; > > } > > > > public void setText(String text) { > > this.text = text; > > } > > } > > > > From the code below, I can insert entities in the database but (commented > > out code) but getting an exception while finding any entity: > > > > package com.wrwlf.test.dao; > > > > import java.util.Properties; > > > > import javax.persistence.EntityManager; > > import javax.persistence.EntityManagerFactory; > > import javax.persistence.Persistence; > > > > import com.wrwlf.dao.client.Client; > > import com.wrwlf.dao.client.ClientInfo; > > import com.wrwlf.dao.client.TestTable; > > > > public class DAOTest { > > > > /** > > * @param args > > */ > > public static void main(String[] args) { > > // TODO Auto-generated method stub > > > > Properties props=new Properties(); > > props.put("ConnectionURL", > > "jdbc:mysql://localhost:3306/wrwlfdb"); > > props.put("ConnectionDriverName", > "com.mysql.jdbc.Driver"); > > props.put("ConnectionUserName", "root"); > > props.put("ConnectionPassword", "root"); > > > > EntityManagerFactory > > factory=Persistence.createEntityManagerFactory("masterdb"); > > EntityManager manager=factory.createEntityManager(); > > > > /* > > TestTable obj1=new TestTable(); > > obj1.setId("id2");obj1.setText("again some text"); > > > > manager.getTransaction().begin(); > > manager.persist(obj1); > > manager.getTransaction().commit(); > > */ > > TestTable obj2=manager.find(TestTable.class, "id1"); > > System.out.println(obj2); > > } > > > > } > > > > The exception is as follows: > > > > 109 masterdb INFO [main] openjpa.Runtime - Starting OpenJPA 2.0.1 > > 265 masterdb INFO [main] openjpa.jdbc.JDBC - Using dictionary class > > "org.apache.openjpa.jdbc.sql.MySQLDictionary". > > Exception in thread "main" <openjpa-2.0.1-r422266:989424 nonfatal store > > error> org.apache.openjpa.persistence.EntityNotFoundException: Cannot > > perform find using null object id. > > FailedObject: null [java.lang.String] > > at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:898) > > at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:880) > > at > > > org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:223) > > at > > > > > org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:477) > > > > at com.wrwlf.test.dao.DAOTest.main(DAOTest.java:38) > > > > The entity with the following id is present in the database, the database > > itself is very simple with two columns, id - VARCHAR(10) and text- > > VARCHAR(50) > > > > Could someone please help me to resolve this. > > > > Thanks & regards > > > > Sanjay Debnath > > >
