- This topic has 9 replies, 3 voices, and was last updated 16 years, 11 months ago by Riyad Kalla.
-
AuthorPosts
-
Klaus VillacaMemberHello, I’m trying the JPA from the MyEclipse 5.5M2, and I’ve found some problems, like this kind off error, and what I’ve to do to fix this. Is only a test
Here is my XML :
<?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=”persistence1″ transaction-type=”RESOURCE_LOCAL”>
<provider>mysql.toplink.essentials.PersistenceProvider</provider>
<class>entity.Login</class>
<class>entity.Client1</class><properties>
<property name = “toplink.jdbc.driver” value = “com.mysql.jdbc.Driver”/>
<property name = “toplink.jdbc.url” value = “jdbc:mysql://127.0.0.1:3306/client”/>
<property name = “toplink.jdbc.user” value = “root”/>
<property name = “toplink.jdbc.password” value = “test”/>
</properties>
</persistence-unit>
</persistence>Part of client program client :
// Create EntityManagerFactory for persistent unit named “pu1”
// to be used in this test
emf = Persistence.createEntityManagerFactory(“persistence1”);// Persist all entities
createTransactionalEntityManager();
System.out.println(“Inserting Customer and Orders… ” + testInsert());
closeTransactionalEntityManager();
.
.
.
Riyad KallaMember<provider>mysql.toplink.essentials.PersistenceProvider</provider>
The problem is your persistence provide is invalid… it should be something like:
oracle.toplink.essentials.PersistenceProvider
Klaus VillacaMemberOk Tnhks
However now I’d have another problem… I’d can get connected on my MySQL, but I just can do the insert of new records, and use the findid, all the other issues like delete, update, doesnt work. And the strange is, after I did the delete, the programa show to me that are all fine, and if I’d try one another findid he throw one erro to me, but after I go and check on the database, the register still there!!!
Thank you
Riyad KallaMemberIt sounds like you need to make use of transactions with your inserts and deletes. It looks like:
EntityManagerHelper.beginTransaction(); <YOUR SAVE or DELETE OPERATION> EntityManagerHelper.commit();
Klaus VillacaMemberMan,
I`m really have to say thank you. I know that I`’m young on this API, and I`d still a lot to learn and I`d either know that is a stupid thing.
Once again thank you.
Riyad KallaMemberNo problem. Using persistence APIs (this can happen with hibernate too) has some little “quirks” to it, but once you figure them out you can just start banging out the persistence code without much of a problem.
The first time I ever ran into that issue “why aren’t my values changing!?” it took me a lot of crazy to figure out I needed transactions 😉
Robert JewettMemberThis message has not been recovered.
Riyad KallaMemberThis message has not been recovered.
Robert JewettMemberThis message has not been recovered.
Riyad KallaMemberThis message has not been recovered.
-
AuthorPosts