Previously I was only retrieving the information from database using HQL queries, it worked fine. This time I had to insert some information their. And I suddenly found out that it is not that trivial.
HQL doesn't support INSERT... VALUES... at all. (Security reasons, I suppose). The documentation says it supports INSERT INTO...SELECT... and gives some examples about that. But when I try to run such queries they show an exception: "query must begin with SELECT or FROM".
I wonder, how could that be, if in their own documentation (http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html) they state that this:
insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...
should work.
I am puzzled about how to do it properly. Their is absolutely not enough time to change the architecture now. If anybody has any suggestions, feel free to express them.
Update on the 13.02.2011: I am sure it is possible to insert info into the database using Hibernate, but I couldn't find any trivial way. Due to the time limitations I will have to exclude that from the project scope.
Update on the 29.06.2011: At last found the solution for this issue! See post from 29.06.2011
HQL doesn't support INSERT... VALUES... at all. (Security reasons, I suppose). The documentation says it supports INSERT INTO...SELECT... and gives some examples about that. But when I try to run such queries they show an exception: "query must begin with SELECT or FROM".
I wonder, how could that be, if in their own documentation (http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html) they state that this:
insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...
should work.
I am puzzled about how to do it properly. Their is absolutely not enough time to change the architecture now. If anybody has any suggestions, feel free to express them.
Update on the 13.02.2011: I am sure it is possible to insert info into the database using Hibernate, but I couldn't find any trivial way. Due to the time limitations I will have to exclude that from the project scope.
Update on the 29.06.2011: At last found the solution for this issue! See post from 29.06.2011
No comments:
Post a Comment