I have a problem creating a custom query.
These are the same entities:
@Entiree Public Class Application Process {@CollectionOfElements Personal Set & lt; Templates & gt; DefaultTemplates; // more field}
and template.Java @Embeddable @EqualsAndHashCode (exit = {"used"}) applies the public class template Comparable & lt; Templates & gt; {@ Private personal process application process; @ Personal Private Boolean used = boolean.value (wrong); Public template () () {} Get the public application process public process process () {Return application process; } @column (drains = false) @notnew public string getName () {return name; } @column (Nalabel = true) public boolean is used () {used; } To compare public differences (template o) {return getName (). Compare (o.getName ()); }} I want to make an update statement. I have tried these two attempts:
int v = entityManager.createQuery ("Update ApplicationProcess_defaultTemplatesT t.used = true" + "Where t.applicationProcess.id =: apId") . SetParameter ("ApId", ap.getId ()) .executeUpdate ();
ApplicationProcess_defaultTemplates is not mapped [Update ApplicationProcess_defaultTemplatesTy t.used = true WHERE t.applicationProcess.id =: apId]
int v = entityManager.createQuery ("Update Template t set t.used = true" + "WHERE t.applicationProcess.id =: apId"). SetParameter ("apId", Ap.getId ()) .executeUpdate ();
with the same error:
The template is not mapped [Update Template T set t.used = true WHERE t.applicationProcess.id =: Apid]
Any ideas?
UPDATE
I have decided to make it the original query
int v = entityManager.createNativeQuery ("Update ApplicationProcess_defaultTemplates T set t.used = true where t.ApplicationProcess_id =: apId "). SetParameter ("apid", ap.getId ()). ExecuteUpdate ();
What you want to do is not possible in HQL: as are the embedded objects , They can not appear in the section of the HQ questions. And you need this to make that object update.
So you have two possibilities:
- Use either a SQL query (be careful)
- For a unit, your template class Reactor
Comments
Post a Comment