on 03-19-2009 4:19 PM
Hello Experts
I have a problem whem i persist a entity.
Often the instance of entity don't persist when i call method persist().
I don't know what happen. The method don't cause any error, but don't have any registry in the database after passing the persist() method.
Att.
Marcos
Hi Marcos,
persist() only registers an entity to be inserted upon flush. If you don't commit, no flush occurs and your changes are lost.
Sure you are commiting your transaction?
-Adrian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adrian
Thanks for your quickly reply.
i don't use the method flush. But in other entity, i do the same process and the data is commit in database. i've compared these two entity, and they are equals. the only diference is the quantity of attributes in both.
I try to use the method flush in both entity. In the first is OK, the data is commited. In the second cause one error.
When i don't use the method flush, the same happend, the first commit, the second don't commit, but don't cause error.
Waiting for anwser.
Thanks.
Marcos.
Hi
this is the error that i get:
javax.persistence.PersistenceException: SQL exception while inserting entity: Class >>br.com.teclogica.demo.mobile.entity.LogClientIncidentes<<. Id values: (idLog=1).
and the error message:
SQL exception while inserting entity: Class >>br.com.teclogica.demo.mobile.entity.LogClientIncidentes<<. Id values: (idLog=1).
The table in database is empty, and the sequence isn't start.
Thanks.
Marcos
Hi Adrian,
I found in archive "database_00.0.log" the SQL error cause this problem.
Now i fixed the error and the data is commited in the database.
But it is a realy big problem. When the database throw some error, the method persist don't throw any error. Its just do nothing, the process to persist like normal with no error to the application.
I believe this behavoir isn't normal.
Have you seen anything like this?
Thanks.
Marcos.
Hi Adrian
Now i understood...
When i use persist without flush, the entity will be persist in database, but don't in the exactly moment when this method is called. If ocurr some error, this error cannot be throw, because the process of persist will ocurr in the future. When i called flush method, the process of persist will be complete in the moment when i called it, and if ocurr some error, this error will be threw.
Is this right?
Thanks for your help Adrian.
Marcos
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.