[jboss-jira] [JBoss JIRA] (HIBERNATE-172) Hibernate generates no needed update statement
nimo stephan (Jira)
issues at jboss.org
Tue Mar 31 05:52:22 EDT 2020
[ https://issues.redhat.com/browse/HIBERNATE-172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
nimo stephan updated HIBERNATE-172:
-----------------------------------
Description:
I have an orderinary entity with this property:
{code:java}
@Entity
@DynamicUpdate
public class User {
@Convert(converter = TaskConverter.class)
private Map<Task, Type> tasks;
..
}
{code}
where the `Task` is an Enum-class and the `Type` is another Enum-class. The converter converts the tasks to a string and back. All works, however, Hibernate generates an additional update statement for the `tasks` when I create a new `User`-Instance or update other entity properties of the `User`-instance:
{code:java}
// this update statement is always created altough "tasks" was not changed
update User set tasks=? where id_user=?
{code}
The above update statement always follows after another update statement of the same entity. For example:
{code:java}
// here I only change the name property and an update is triggered
update User set name=? where id_user=?
// but then hibernate also creates this update statement even if I did not change tasks
update User set tasks=? where id_user=?
{code}
It behaves as if `tasks` would be an @ElementCollection where the tasks is always recreated on create or update of its parent entity `User`. However, I annotated it with `@Convert`.
Hibernate should not generate an update statement if `tasks` is left unchanged.
was:
I have an orderinary entity with this property:
{code:java}
@Entity
@DynamicUpdate
public class User {
@Convert(converter = TaskConverter.class)
private Map<Task, Type> tasks;
..
}
{code}
where the `Task` is an Enum-class and the `Type` is another Enum-class. The converter converts the tasks to a string and back. All works, however, Hibernate generates an additional update statement for the `tasks` when I create a new `User`-Instance or update other entity properties of the `User`-instance:
{code:java}
// this update statement is always created altough "tasks" was not changed
update User set tasks=? where id_user=?
{code}
It behaves as if `tasks` would be an @ElementCollection where the tasks is always recreated on create or update of its parent entity `User`. However, I annotated it with `@Convert`.
Hibernate should not generate an update statement if `tasks` is left unchanged.
> Hibernate generates no needed update statement
> ----------------------------------------------
>
> Key: HIBERNATE-172
> URL: https://issues.redhat.com/browse/HIBERNATE-172
> Project: Hibernate Integration
> Issue Type: Bug
> Reporter: nimo stephan
> Assignee: Steve Ebersole
> Priority: Major
>
> I have an orderinary entity with this property:
> {code:java}
> @Entity
> @DynamicUpdate
> public class User {
>
> @Convert(converter = TaskConverter.class)
> private Map<Task, Type> tasks;
>
> ..
> }
> {code}
> where the `Task` is an Enum-class and the `Type` is another Enum-class. The converter converts the tasks to a string and back. All works, however, Hibernate generates an additional update statement for the `tasks` when I create a new `User`-Instance or update other entity properties of the `User`-instance:
>
> {code:java}
> // this update statement is always created altough "tasks" was not changed
> update User set tasks=? where id_user=?
> {code}
> The above update statement always follows after another update statement of the same entity. For example:
> {code:java}
> // here I only change the name property and an update is triggered
> update User set name=? where id_user=?
> // but then hibernate also creates this update statement even if I did not change tasks
> update User set tasks=? where id_user=?
> {code}
> It behaves as if `tasks` would be an @ElementCollection where the tasks is always recreated on create or update of its parent entity `User`. However, I annotated it with `@Convert`.
> Hibernate should not generate an update statement if `tasks` is left unchanged.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list