save « Transaction « JPA Q&A





1. Optimize Hibernate entities saving?    stackoverflow.com

Hi Is there a way to reduce unnecessary/empty fields in SQL inserts and SQL updates? For example, I have a single hibernate entity class mapped to a table that has 10 columns. The ...

2. want each call to save to commit    stackoverflow.com

How can I have each call to save commit to the database? I don't want to, at each interation of a loop that I am in, to call commit and then restart ...

3. Hibernate save() and transaction rollback    stackoverflow.com


In Hibernate when i save() an object in a transaction, and then i rollback it, the saved object still remains in the DB. It's strange because this issue doesn't happen ...

4. Hibernate is saving a completely new entity automaticaly(full stack of calls)    stackoverflow.com

there. I have already asked this question two times, but I'm new to stackoverflow and it seems that I don't know the rules for formatting my example code ...

5. Hibernate: Need to save the same object twice within the transaction    stackoverflow.com

I need to save the same object twice within transaction, but hibernate always have only one sql update, any way to do it? Here is the code:

....
session.beginTransaction();
Student s = session.get(Student.class, id);

// (1) ...

6. Hibernate Save, Hibernate Rollback    stackoverflow.com

I'm trying to make my DAO work this way:

    public void incrementNumber(long id) throws Exception{
        Session session = factory.openSession();
   ...

7. Entity incorrectly being saved during transaction    forum.hibernate.org

I'm using JPA, Hibernate 3.3 and Spring Transactions my database access. I'm noticing odd behavior during a transaction. Essentially if I pull an entity and then make modifications to it but never actually call the merge or persist function in the EntityManager Hibernate still saves all my changes. Unfortunately I can't just make my changes outside of the transaction so i'm ...

9. Does a commit save a transaction    forum.hibernate.org

I'm now in charged of the following code and I 'm not sure if I correctly understand what the guy was doing .. void methodA(){ sess=SessionFactory.openSession(); tx=sess.beginTransaction(),; myobj1 = sess.get(MyObj1.class , anInt), myobj2 = myobj1.cloneDeep(); sess.save(myobj2) ; myobj1.setAttrib1(newvalue); myobj1.setAttrib2(newvalue); tx.commit(); sess.close(); } myobj1 and 2 are local vars not instVar. What happens here ?? I understand that myobj2 will be newly ...





10. Hibernate save() and transaction rollback    forum.hibernate.org

Hi, When i save() an object in a transaction, and then i rollback it, the saved object still remains in the DB. It's strange because this issue doesn't happen with the update() or delete() method, just with save(). Here is the code i'm using: Code: DbEntity dbEntity = getDbEntity(); HibernateUtil.beginTransaction(); Session session = HibernateUtil.getCurrentSession(); session.save(dbEntity); HibernateUtil.rollbackTransaction(); And here is the HibernateUtil ...

11. save(obj) does not commit the JDBC transaction    forum.hibernate.org

Dear, I'm using an application server (wasce) connection pool trought Hibernate to connect an Oracle database. When I do a "getSession().save(Obj)" , the object is saved in my Hibernate session, but it is not saved in the database even with a flush. To synchronize the database, i had to add a "getSession().connection().setAutoCommit(true);" and now, it works. However, Session.connection() is now deprecated ...

13. Save and update object in same transaction    forum.hibernate.org

my requirement is that i want to save an object and after saving it update that object with other related data (all in same transaction, since i am using @Transcational annotation on service class level), here's a code snippet: - Service: Code: @Service @Transactional public class MyService {` public Employee ...

14. Did not save to database (caused table lock I think)    forum.hibernate.org

Newbie Joined: Tue Jan 06, 2004 12:57 am Posts: 14 I have been trying to get a sample working and its almost there except the data is not getting saved to the database (retrieval is ok). I am using SQL Server and the Microsoft jdbc driver. There is no error from Hibernate on the console: Hibernate: insert into item (name, description) ...

15. Does tx.rollback undo a session save?    forum.hibernate.org

Hi there, I would like to know if i have a Session s = factory.openSession(); Transaction tx = s.beginTransaction(); ....... tx.commit(); s.close(); block like this, and in the middle of it i create a new object and session.save() it but however, further down the line but before the tx.commit(), an error occurs and tx.rollback is called, would the saving of the ...

16. Transaction session.save ,session.rollback and session.flush    forum.hibernate.org

Beginner Joined: Wed Sep 24, 2003 8:27 am Posts: 36 Team, I have some code like this Code: method{ do{t = session.transaction; try{ t.begintransaction ...





18. save without commit results in stale data    forum.hibernate.org

Newbie Joined: Thu Sep 02, 2004 8:16 am Posts: 4 I am adding transient objects to a session without actually committing or rolling back a transaction. When closing the session, opening a new session and executing a find on this newly created session it returns me the non committed objects. Trying session.clear, evict or sessionFactory.evict does not resolve this behaviour. Seems ...

19. can I save multiple objects in a transaction?    forum.hibernate.org

Hibernate does nothing special or extra in terms of transaction handling. So there is no limit imposed thus you can structure your code to do a full transaction cycle per-iteration or do a subset of the data or all of the data in a single transaction. Which way you go depends on the use case requirements.

20. Saving with no transaction...    forum.hibernate.org

Beginner Joined: Fri Oct 10, 2003 10:12 am Posts: 39 Hi ng, This is a simple question but one that i have been unable to find a clear answer for (it could be that i have configured something incorrectly ot that my db dosen't support it). Basically i was hoping someone could tell me if it is a requirement that you ...

21. Save works only within Transaction    forum.hibernate.org

Ahem..... What seems to be the problem? How can you save and object and expect it to appear in the database without committing your save? You've probably grown used to the autocommit flag being set to 'true' on the java.sql.Connection object (the default value) and therefore have assumed that an insert does not require a transaction. It always does - just ...

22. Deadlock on beginTransaction;lock(obj);save(obj);commit    forum.hibernate.org

Newbie Joined: Sat May 07, 2005 12:22 pm Posts: 3 I am having a lot of problems getting Hibernate to properly lock. I have read through all of the documentation on this, and a lot of posts. However, I cannot figure out what is going on in my code. I have simplified the test down to a very basic table, and ...

24. Limitation on number of saves in a transaction?    forum.hibernate.org

I have a very simple bean mapped to a single table. I wrote a small program to pre-load the table with a bunch of entries for further testing. The "load" code is structured as: Code: Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); ...

25. Save succeeding queries within one Transaction    forum.hibernate.org

Hi folks, I want to execute several update queries, which values originate from an csv-file, within one transaction. Some of the queries might break a constraint of the table, for example trying to insert an value being unique in another row of the table. The problem is, if one of the queries failes, the whole transaction failes (atomicity). Is there a ...

26. How to make data not save without call update in transaction    forum.hibernate.org

If you change something in an object, and your cascade setting is enabled (e.g. set to save-update), Hibernate will detect that change and persist it to db whenever you close the session (it checks for updates during session closing). You can put this line into your config file: false This should disable the auto-flush during session commit. However, from there ...

27. Transactions and Saving Transient Objects    forum.hibernate.org

Hi, here is my scenario. Points will be given fairly! Simply, the question is, why in my configuration, does the session.save method call not obey transactions for transient objects? here are the details: I created a new transitive object (Parent), and this transient object has a one to many mapping to another object (Child). Here are my mappings: Parent:

28. Changes made to objects get committed without calling save.    forum.hibernate.org

I have a Spring application that uses Hibernate together with JTA. Recently I found out that on the service layer when an Hibernate object was loaded and some parameter changed as a result, the changes later occurred in database although getHibernateTemplate().saveOrUpdate(myObject); or any other save method was never called for that object. It came out that all the changes made to ...

29. persistent instance not saved after obtaining a lock    forum.hibernate.org

Thanks Shanta, I am checking for versionging. Here is how i am using .but it is not updating the database.I am trying to use the same persistant instance to check how th versioning works with multiple Hibernate sessions. Any more additions for checking ?. Code: Session session = HibernateSessionFactory.getInstance().getHibernateSession(); department = (Department)session.createCriteria(Department.class) ...

31. CascadeType.SAVE_UPDATE and potential deadlock problm    forum.hibernate.org

I am a toplink user and as you may know one of the features of toplink is it accesses a collection of entities always in a same way (for example when saving updated entities to database it starts saving the entity with lowest primary key and goes on in an ascending manner). This prevents many potential deadlock situation when concurrent users ...

33. Multiple save(object) in single transaction    forum.hibernate.org

Dear All, I am new to hibernate. Please help me regarding the multiple save object within single transaction. try { Transaction tx = session.beginTransaction(); session.save(emp); session.save(dept); tx.commit; } catch (Exception e) { tx.rollback; } Above code is saving "emp" and "dept" object in single transaction. If "session.save(emp)" is executed properly but "session.save(dept)" given error, while executing "tx.commit". My question is, if ...