[JIRA] (BVAL-757) Lazy fetch type doesn't work for identical objects
by Xset (JIRA)
Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Bean Validation ( https://hibernate.atlassian.net/browse/BVAL?atlOrigin=eyJpIjoiOWMyN2M2NTU... ) / Bug ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiOWMyN2M... ) BVAL-757 ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiOWMyN2M... ) Lazy fetch type doesn't work for identical objects ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiOWMyN2M... )
Change By: Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
There is User Entity:
{code:java}@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
...
@ Column(nullable = false)
@ OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<UserPermission> permissions;
}{code}
There is Permission Entity:
{code:java}@Entity
@Table(name = "user_permissions", indexes = {@Index(unique = true, columnList = "id")})
public class UserPermission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", referencedColumnName = "id")
public User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_user_id", referencedColumnName = "id")
public User targetUser;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "other_entity", referencedColumnName = "id")
public OtherEntity otherEntity;
}{code}
I use this code to fetch User Entity:
{code:java}... get session
... open transaction
// fetching user
final User user = session.find(User.class, id);
// fetching permissions
final Set<UserPermission> userPermissions = user.permissions;
// foreach permissions
// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER
for (UserPermission permission: userPermissions) {
// there is no code
}
... close transaction{code}
Look at the comment in code above:
{code:java}// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER{code}
It means, that without any calls to targetUser, hibernate fetches it. That's really strange. This behavior really slows down performance of my application.
My assumption: Hibernate just can't proxy two similar objects in one entity (i mean, user and targetUser have the same class, hibernate cannot proxy both objects and thats why it fetches targetUser immediately)
How to solve this problem? Any suggestions?
( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... ) Add Comment ( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:33445dc )
4 years, 4 months
[JIRA] (BVAL-757) Lazy fetch type doesn't work for identical objects
by Xset (JIRA)
Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Bean Validation ( https://hibernate.atlassian.net/browse/BVAL?atlOrigin=eyJpIjoiMzAzNDJkNzd... ) / Bug ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiMzAzNDJ... ) BVAL-757 ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiMzAzNDJ... ) Lazy fetch type doesn't work for identical objects ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiMzAzNDJ... )
Change By: Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
There is User Entity:
{code:java}@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
...
@Column(nullable = false)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<UserPermission> permissions;
}{code}
There is permission entity Permission Entity :
{code:java}@Entity
@Table(name = "user_permissions", indexes = {@Index(unique = true, columnList = "id")})
public class UserPermission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", referencedColumnName = "id")
public User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_user_id", referencedColumnName = "id")
public User targetUser;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "other_entity", referencedColumnName = "id")
public OtherEntity otherEntity;
}{code}
I use this code to fetch user entity User Entity :
{code:java}... get session
... open transaction
// fetching user
final User user = session.find(User.class, id);
// fetching permissions
final Set<UserPermission> userPermissions = user.permissions;
// foreach permissions
// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER
for (UserPermission permission: userPermissions) {
// there is no code
}
... close transaction{code}
Look at the comment in code above:
{code:java}// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER{code}
It means, that without any calls to targetUser, hibernate fetches it. That's really strange. This behavior really slows down performance of my application.
My assumption: Hibernate just can't proxy two similar objects in one entity (i mean, user and targetUser have the same class, hibernate cannot proxy both objects and thats why it fetches targetUser immediately)
How to solve this problem? Any suggestions?
( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... ) Add Comment ( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:33445dc )
4 years, 4 months
[JIRA] (BVAL-757) Lazy fetch type doesn't work for identical objects
by Xset (JIRA)
Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Bean Validation ( https://hibernate.atlassian.net/browse/BVAL?atlOrigin=eyJpIjoiYTZlMTVmZTU... ) / Bug ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiYTZlMTV... ) BVAL-757 ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiYTZlMTV... ) Lazy fetch type doesn't work for identical objects ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiYTZlMTV... )
Change By: Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
There is User Entity:
{code:java}
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
...
@Column(nullable = false)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<UserPermission> permissions;
}
{code}
There is permission entity:
{code:java}
@Entity
@Table(name = "user_permissions", indexes = {@Index(unique = true, columnList = "id")})
public class UserPermission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", referencedColumnName = "id")
public User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_user_id", referencedColumnName = "id")
public User targetUser;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "other_entity", referencedColumnName = "id")
public OtherEntity otherEntity;
}
{code}
There is User Entity:
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
...
@Column(nullable = false)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<UserPermission> permissions;
}
There is permission entity:
@Entity
@Table(name = "user_permissions", indexes = {@Index(unique = true, columnList = "id")})
public class UserPermission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", referencedColumnName = "id")
public User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_user_id", referencedColumnName = "id")
public User targetUser;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "other_entity", referencedColumnName = "id")
public OtherEntity otherEntity;
}
I use this code to fetch user entity:
{code:java}
... get session
... open transaction
// fetching user
final User user = session.find(User.class, id);
// fetching permissions
final Set<UserPermission> userPermissions = user.permissions;
// foreach permissions
// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER
for (UserPermission permission: userPermissions) {
// there is no code
}
... close transaction
{code}
Look at the comment in code above:
{code:java}
// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER
{code}
It means, that without any calls to targetUser, hibernate fetches it. That's really strange. This behavior really slows down performance of my application.
My assumption: Hibernate just can't proxy two similar objects in one entity (i mean, user and targetUser have the same class, hibernate cannot proxy both objects and thats why it fetches targetUser immediately)
How to solve this problem? Any suggestions?
( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... ) Add Comment ( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:33445dc )
4 years, 4 months
[JIRA] (BVAL-757) Lazy fetch type doesn't work for identical objects
by Xset (JIRA)
Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Bean Validation ( https://hibernate.atlassian.net/browse/BVAL?atlOrigin=eyJpIjoiYjNlMTU2NDA... ) / Bug ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiYjNlMTU... ) BVAL-757 ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiYjNlMTU... ) Lazy fetch type doesn't work for identical objects ( https://hibernate.atlassian.net/browse/BVAL-757?atlOrigin=eyJpIjoiYjNlMTU... )
Issue Type: Bug Assignee: Unassigned Created: 31/Jul/2020 11:06 AM Priority: Major Reporter: Xset ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
There is User Entity:
@Entity
@Table(name = "users" )
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
...
@Column(nullable = false )
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user" )
public Set<UserPermission> permissions;
}
There is permission entity:
@Entity
@Table(name = "user_permissions" , indexes = {@Index(unique = true , columnList = "id" )})
public class UserPermission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id" , referencedColumnName = "id" )
public User user;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_user_id" , referencedColumnName = "id" )
public User targetUser;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "other_entity" , referencedColumnName = "id" )
public OtherEntity otherEntity;
}
There is User Entity:
@Entity
@Table(name = "users")
public class User
{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) public Long id; ... @Column(nullable = false) @OneToMany(fetch = FetchType.LAZY, mappedBy = "user") public Set<UserPermission> permissions; }
There is permission entity:
@Entity
@Table(name = "user_permissions", indexes =
{@Index(unique = true, columnList = "id")}
)
public class UserPermission
{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) public Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", referencedColumnName = "id") public User user; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "target_user_id", referencedColumnName = "id") public User targetUser; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "other_entity", referencedColumnName = "id") public OtherEntity otherEntity; }
I use this code to fetch user entity:
... get session
... open transaction
// fetching user
final User user = session.find(User.class, id);
// fetching permissions
final Set<UserPermission> userPermissions = user.permissions;
// foreach permissions
// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER
for (UserPermission permission: userPermissions) {
// there is no code
}
... close transaction
Look at the comment in code above:
// HIBERNATE FETCHES HERE targetUser AND EVERYTHING CONNECTED TO THIS ENTITY, LOOKS LIKE FetchType.EAGER
It means, that without any calls to targetUser, hibernate fetches it. That's really strange. This behavior really slows down performance of my application.
My assumption: Hibernate just can't proxy two similar objects in one entity (i mean, user and targetUser have the same class, hibernate cannot proxy both objects and thats why it fetches targetUser immediately)
How to solve this problem? Any suggestions?
( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... ) Add Comment ( https://hibernate.atlassian.net/browse/BVAL-757#add-comment?atlOrigin=eyJ... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:33445dc )
4 years, 4 months