- This topic has 26 replies, 3 voices, and was last updated 14 years ago by support-shalini.
-
AuthorPosts
-
JamesRaynorMemberguess i talked to soon,well at least i can see something besides “<unsupported>” in the query browser,
but the problem persists, i tried what you said.
i did the following:
1 i changed the openjpa.jar file to the one you specified
2 changed a bit the test code topublic class runJPA { public static void main(String[] args) { // var just to fill a fake table int d = 10; String t = "estado"; // my instance Prueba3 id = new Prueba3(d, t); // to verify if the instance is filled with the right info System.out.println("folio: "+id.getFolio() + " tonterias: " + id.getTonterias()); // the DAO Prueba3DAO dao = new Prueba3DAO(); // the TX EntityManagerHelper.beginTransaction(); dao.save(id); EntityManagerHelper.commit(); } }
and get the following error
folio: 10 tonterias: estado [TopLink Info]: 2010.09.21 04:45:28.453--ServerSession(28311783)--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007)) [TopLink Info]: 2010.09.21 04:45:28.703--ServerSession(28311783)--file:/C:/Documents%20and%20Settings/javier.jaramillo/Workspaces/MyEclipse%208.5/NewJPA/bin/-NewJPAPU login successful 21/09/2010 04:45:28 PM com.myeclipse.jpa.EntityManagerHelper log INFO: saving Prueba3 instance 21/09/2010 04:45:28 PM com.myeclipse.jpa.EntityManagerHelper log INFO: save successful [TopLink Warning]: 2010.09.21 04:45:28.781--UnitOfWork(14615608)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Invalid object name 'dbo.Jv.prueba3'. Error Code: 208 Call: INSERT INTO dbo.Jv.prueba3 (folio, tonterias) VALUES (?, ?) bind => [10, estado] Query: InsertObjectQuery(com.myeclipse.jpa.Prueba3@1d98a) Exception in thread "main" javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Invalid object name 'dbo.Jv.prueba3'. Error Code: 208 Call: INSERT INTO dbo.Jv.prueba3 (folio, tonterias) VALUES (?, ?) bind => [10, estado] Query: InsertObjectQuery(com.myeclipse.jpa.Prueba3@1d98a) at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:105) at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:45) at com.myeclipse.jpa.EntityManagerHelper.commit(EntityManagerHelper.java:46) at com.myeclipse.jpa.runJPA.main(runJPA.java:21) Caused by: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Invalid object name 'dbo.Jv.prueba3'. Error Code: 208 Call: INSERT INTO dbo.Jv.prueba3 (folio, tonterias) VALUES (?, ?) bind => [10, estado] Query: InsertObjectQuery(com.myeclipse.jpa.Prueba3@1d98a) at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:296) at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:639) at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:688) at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:477) at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:437) at oracle.toplink.essentials.internal.sessions.AbstractSession.executeCall(AbstractSession.java:675) at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:213) at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:199) at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:331) at oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:176) at oracle.toplink.essentials.internal.queryframework.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:190) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:457) at oracle.toplink.essentials.queryframework.InsertObjectQuery.executeCommit(InsertObjectQuery.java:74) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedWrite(DatabaseQueryMechanism.java:635) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.performUserDefinedInsert(DatabaseQueryMechanism.java:599) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.insertObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:495) at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeCommitWithChangeSet(WriteObjectQuery.java:130) at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:283) at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:67) at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609) at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536) at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:123) at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:95) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2219) at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937) at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:894) at oracle.toplink.essentials.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:254) at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:175) at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2638) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1030) at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:387) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1112) at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:91) at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:842) at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:87) ... 3 more Caused by: java.sql.SQLException: Invalid object name 'dbo.Jv.prueba3'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546) at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:504) at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:632) ... 36 more
what do you think?
support-shaliniMemberJamesRaynor,
[TopLink Warning]: 2010.09.21 04:45:28.781–UnitOfWork(14615608)–Exception [TOPLINK-4002] (Oracle TopLink Essentials – 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Have you changed your JPA libraries to toplink?
Can you create a new java project, add JPA capabilities and choose Open JPA while adding the capabilities?
Now, if you test your code, it should work.
Let me know if you get any issues.
JamesRaynorMemberalright shalini, we are almost done, i hope
i redid the whole project, but i think the now the problem is i am a newbie :p…
no the problem i get isException in thread "main" java.lang.NullPointerException at EntityManagerHelper.getEntityManager(EntityManagerHelper.java:29) at EntityManagerHelper.beginTransaction(EntityManagerHelper.java:42) at run.main(run.java:20)
the code is basically the same:
public class run { /** * @param args */ public static void main(String[] args) { /* 1. Create a reference to our ID */ int p = 1; /* 2. Create a new Productline instance */ Prueba3 newp = new Prueba3( p, "Shoes"); /* 3. Create a DAO instance to use */ Prueba3DAO dao = new Prueba3DAO(); /* 4. Store our new product line in the DB */ EntityManagerHelper.beginTransaction(); System.out.println("reading....."); dao.save(newp); EntityManagerHelper.commit(); } }
the reading is to check if the EntityManagerHelper is creating a the TX, it seems like its not doing it, checked the EntityManagerHelper class, it seems ok
and the table i am using does have a PK, so its almost the same as in the tutorial// default package import java.util.logging.Level; import java.util.logging.Logger; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import javax.persistence.Query; /** * @author MyEclipse Persistence Tools */ public class EntityManagerHelper { private static final EntityManagerFactory emf; private static final ThreadLocal<EntityManager> threadLocal; private static final Logger logger; static { emf = Persistence.createEntityManagerFactory("NEWPU"); threadLocal = new ThreadLocal<EntityManager>(); logger = Logger.getLogger("NEWPU"); logger.setLevel(Level.ALL); } public static EntityManager getEntityManager() { EntityManager manager = threadLocal.get(); if (manager == null || !manager.isOpen()) { manager = emf.createEntityManager(); threadLocal.set(manager); } return manager; } public static void closeEntityManager() { EntityManager em = threadLocal.get(); threadLocal.set(null); if (em != null) em.close(); } public static void beginTransaction() { getEntityManager().getTransaction().begin(); } public static void commit() { getEntityManager().getTransaction().commit(); } public static void rollback() { getEntityManager().getTransaction().rollback(); } public static Query createQuery(String query) { return getEntityManager().createQuery(query); } public static void log(String info, Level level, Throwable ex) { logger.log(level, info, ex); } }
i didn’t touch that code, and besides, i don’t know where to touch. :p
support-shaliniMemberJamesRaynor,
emf = Persistence.createEntityManagerFactory(“NEWPU”);
Please verify the name of persistence-unit in your persistence.xml, it should be “NEWPU”.
If the issue still persists, can you copy paste your persistence.xml here?
JamesRaynorMemberguess what?
it is “NEWPU”
the persistence.xml is as follows:<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="NEWPU" transaction-type="RESOURCE_LOCAL"> <provider> org.apache.openjpa.persistence.PersistenceProviderImpl </provider> <class>Prueba3</class> <properties> <property name="openjpa.ConnectionDriverName" value="net.sourceforge.jtds.jdbc.Driver" /> <property name="openjpa.ConnectionURL" value="jdbc:jtds:sqlserver://localhost:1433/JV" /> <property name="openjpa.ConnectionUserName" value="sa" /> <property name="openjpa.ConnectionPassword" value="dgcv2010" /> </properties> </persistence-unit> </persistence>
Bojan KaurinMemberI have a question similar to this one, well not quite, but similar. I need to do forward engineering. I created java project and one simple class. Then I added JPA capabilities and set database settings for this project and generated JPA annotations on this class. Now i need to generate database tables(table, because there is only one class) from this JPA annotations, and I don’t know how? In eclipse with dali plugin there is option generate tables from entities and that works, but i can’t find something like this in myeclipse. How can I do this in myeclipse(for single(my example) and multiple classes(entities))?
support-shaliniMemberJamesRaynor,
Can you share your project? You can send a mail, with your project attached, to support@genuitec.com with ATTN:Shalini in the subject a reference to this post.
This will help me replicate your issue at my end.bojankaurin,
I have replied to your post here –
https://www.genuitec.com/forums/topic/forward-engineering-pojos-to-database-jpa-hibernate/#post-311501
JamesRaynorMemberdid you get the mail i sent?????
or do i send it again?????????
JamesRaynorMemberoops!!!!
i saw the reply on the not-so-often-checked mail acountcan you resend it to the mail i putted on the reply i couldnt see the persistance.xml
support-shaliniMemberJamesRaynor,
Here is my reply –
I could not replicate your issue with the project sent to me. The only changes that I made were to the persistence.xml to connect to my
database. I have attached some screen shots for your reference.For debugging, I would recommend you to go through the following link –
http://www.myeclipseide.com/documentation/quickstarts/webprojects/#deploy_testing_debug
This is based on web applications but you can follow on similar lines for java projects.
Let me know if that helpsAttachments:
You must be logged in to view attached files.
JamesRaynorMemberoops!
never told ya that this fixed the problem.
thank you very much.
support-shaliniMemberJamesRaynor,
Good to know that it is working now.
Do let us know if you have any issues -
AuthorPosts