hql « Update « JPA Q&A





1. HQL multiple updates. Is there a better way?    stackoverflow.com

I have a Map, that I want to persist. The domain object is something like this:

public class Settings {
    private String key;
    private String value;

 ...

2. Problem with saveOrUpdate() in hibernate    stackoverflow.com

Recently i am started using hibernate. to insert or update i am using saveOrUpdate() function. If i update an entry i works fine. But, with new entry hibernate generate a Query. Buts ...

3. Hibernate. HQL update user type    stackoverflow.com

Is it possible to update user type field in HQL query? When I am trying to use user type in where clause everything works fine.

  getSession()
      ...

4. problem with HQL update    stackoverflow.com

When I try to execute the following HQL query:

Query  query =  getSession().createQuery("update XYZ set status = 10");
query.executeUpdate();
I get this exception:
Exception in thread "main" org.hibernate.QueryException: query must begin with SELECT ...

5. hibernate remove duplication from hql    stackoverflow.com

this is a question following hibernate what is the right way to load object graph the answer correctly do the work. but because I can not use set(I need order) and ...

6. hibernate HQL update mutliple tables    coderanch.com

Hi. I trying to write an sql to update 2 columns, each columns is in another table. I need an hql. something like update A.col='rr', B.col='aa' from toto as A inner join bobo as B on A.a=B.b I found somethong for an SELECT but I don't knwo how to adapt it to an update. This works: from table1 as a inner ...

8. hibernate hql update error    forum.hibernate.org

Hi All, I have userprofile table in my DB, and in the table i have column userprofilekey as primary key, and userid as another column, TransactionManager.begin(); userProfileDto = (UserProfileDto)getSession().get(UserProfileDto.class, userProfileDto.getId()); userProfileDto.setUserId("WSSuser123"); getSession().update(userProfileDto); TransactionManager.commit(); getSession().close(); when i update from dao class, I am getting the below error [IBM][SQLServer JDBC Driver][SQLServer]Cannot insert duplicate key row in object 'dbo.UserProfile' with unique index 'IXU_UserProfile_2'. any ...

9. problem with HQL update    forum.hibernate.org

Hello I see in the documentation that exits the method query.executeUpdate , but I don't find in Hibernate 2.2 in the example As an example, to execute an HQL UPDATE, use the Query.executeUpdate() method The method is named for those familiar with JDBC's PreparedStatement.executeUpdate(): Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); String hqlUpdate = "update Customer c set c.name = ...





10. Creating Persistent Objects In HQL    forum.hibernate.org

Hi, I am trying to develop to following process and want to see if there's a Hibernate solution for it: I have an Entity A which holds Entity B with Many to One relation (Means Many A can hold one instance of B). Now, I get a long list of B ids and another field. I am looking to do the ...

11. Using Update HQL to update an entire object    forum.hibernate.org

final String hql = "update myClass obj set obj = :obj where obj.id=:id and obj.hash=:hash"; final Query query = txn.getSession().createQuery(hql); query.setParameter("obj", myObject) .setInteger("id", myObject.getId()) ...

12. why can't use the Hql,save me    forum.hibernate.org

13. Hibernate3 and update with HQL    forum.hibernate.org

Hi, I'm using Hibernate3, and can someone please tell me *clearly* or point to documentation that *clearly* states how to do an update using HQL or a native sql query? I've searched the documentation and searched the forums, and I cannot get a clearcut answer if a) Hibernate 3 allows you to do updates using HQL/sql query b) do i have ...

14. org.hibernate.hql.QuerySplitter - no persistent classes    forum.hibernate.org

Hibernate version: 3.1 Name and version of the database you are using: SQL Server 2000 JDK version: 1.6.0 I'm trying to use hibernate to list the column entries for the table 'JDBCDataSource' but at runtime I get this warning: "WARN org.hibernate.hql.QuerySplitter - no persistent classes found for query class: from de.laliluna.example.JDBCDataSource" So my query returns nothing. Any ideas? Yours appreciatively, Nicholas. ...

15. HQL update syntax    forum.hibernate.org

Hi, Maybe I'm just looking int the wrong spot or maybe it isn't possible but can someone provide me with the syntax for updating multiple rows using HQL? For example something like this: update Table set col1=newVal1, col2=newVal2 where col3=aValue and col4=bValue; Obviously that doesn't work or I wouldn't be posting ;p but: update Table set col1=newVal1 where col3=aValue; seems to ...

16. Doing Mass Updates on one Table with Another using HQL    forum.hibernate.org

Newbie Joined: Mon Sep 11, 2006 4:10 pm Posts: 2 I have a question regarding how to use HQL to do a mass update of a database. I am using version 3.1.3 of Hibernate and trying to update a SQLServer 2005 database. I want to do a bulk update of one table with the contents of another. I have tested the ...





17. Update with HQL?    forum.hibernate.org

Hello, I need help to do an update with HQL. I have 2 tables: Table1 id name hash syncflag Table2 id hash I want to set the syncflag if the hash from Table1 is equals the hash from Table1. In MySQL Query Browser this statement go: Update Table1, Table2 set Tabel1.syncflag=1 where Table2.hash=Table1.hash; How I have to write the HQL Statement ...

18. SQl/HQL Update Troubles    forum.hibernate.org

The createSQLQuery itself works but what do I call on the return SQLQuery object to execute the update? .executeUpdate() returns an error starting "Update queries only supported through HQL" .list() or .updateResults() returns an error stating "Can not issue data manipulation statements with executeQuery()" Here's the code I am trying to use. Still having no luck creating 1 HQL statement to ...

19. HQL UPDATE, NOT IN    forum.hibernate.org

20. HQL update    forum.hibernate.org

3.2.3 I want to run a mass update that will take data from one table and update rows from a different table. The SQL should look like this: Code: UPDATE Target SET targetField = src.sourceField FROM Source src, Target tgt WHERE tgt.targetId = ? AND src.nameField = tgt.nameField The objects Target and Source ...

21. "UPDATE" HQL problem    forum.hibernate.org

Hello I am trying to use update hql as follows: update ProjectType set financial.id = 2 from ProjectType pt, Project p where pt.project_type_id = p.project_type_id and p.id = 456 Is there anything wrong with the following? I get error as unexpected token from. If this is incorrect then how to write update hql? Thanks

22. HQL syntax for update statment with upper bound on rec num    forum.hibernate.org

Hibernate version: 3.2.3 How do I specify, in HQL, an update statement that will update a subset, bound by some number n, of a matching set of records? In SQL (and Oracle), I could do something like: update EVENT_TABLE set STATE = 'new value' where rowid in ( select rowid from EVENT_TABLE where STATE = 'some value' and rownum <= 5); ...

23. HQL Update Example    forum.hibernate.org

I am trying to create an HQL Update statement and would like someone to provide me an example with a simple join on another table. Here is the basic example I am looking for: update tablea set cola where tablea.cola = tableb.cola and tablea.colb = tableb.colb Any help is appreciated. Joe I found a way that works and I am posting ...

24. HQL update    forum.hibernate.org

Hello, I would like rewrite following SQL query to HQL: update mf_rezerwacja MR set rezerwacja = rezerwacja - ( SELECT sum( MO.kwota ) FROM mf_operacja_na_zadaniu MO where MR.rok = MO.rok ) and in all cases my HQL give error : right-hand operand of a binary operator was null HQL: update MfRezerwacja MR set MR.rezerwacja = MR.rezerwacja - ( select sum( MO.kwota ...

25. HQL and UPDATE    forum.hibernate.org