Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Can not retrieve hibernate entity from redis cache: failed to lazily initialize a collection

$
0
0

I am using spring boot and hibernate. as cache i am using redis and GenericJackson2JsonRedisSerializer.

When I try to retrieve my entity from cache iI am getting:

Failure getting from cache: user_entity. Could not read JSON: failedto lazily initialize a collection: could not initialize proxy - noSession (through reference chain:com.avid.identity.service.entity.User["identities"]

I was trying to change Lazy on Eager, it did not help.Please see entity below.

@Getter@Setter@ToString(of = {"id"})@EqualsAndHashCode(of = {"id"})@Entity@NoArgsConstructor@Table(name = "user", schema = "identity")public class User {@Id@GeneratedValue(generator = "uuid4")@GenericGenerator(name = "UUID", strategy = "uuid4")@Column(columnDefinition = "CHAR(36)")private UUID id;@Fetch(FetchMode.JOIN)@JoinColumn(name = "last_authentication_id", referencedColumnName = "id")@OneToOne(fetch = FetchType.LAZY, orphanRemoval = true)private AuthenticationEvent lastAuthentication;@Fetch(FetchMode.JOIN)@JoinTable(name = "user_identities", joinColumns = {        @JoinColumn(name = "user_id")}, inverseJoinColumns = {        @JoinColumn(name = "user_identity_id")})@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)private List<Identity> identities;@Fetch(FetchMode.JOIN)@JoinTable(name = "user_roles", joinColumns = {        @JoinColumn(name = "user_id")}, inverseJoinColumns = {        @JoinColumn(name = "role_id")})@OneToMany(fetch = FetchType.LAZY)private List<Role> roles;@Fetch(FetchMode.JOIN)@JoinColumn(name = "tenant_id", referencedColumnName = "id")@OneToOne(fetch = FetchType.LAZY)private Tenant tenant;

Please help.Thank You


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>