user3364181
user3364181

Reputation: 541

JHipster Spring boot : org.hibernate.HibernateException: Unable to access lob stream

I created my app using JHipster. When i try to get list of tournaments via TournamentQueryService i get this error :

Exception in TournamentQueryService.findByCriteria() with cause = 'org.hibernate.HibernateException: Unable to access lob stream' and exception = 'Unable to access lob stream; nested exception is org.hibernate.HibernateException: Unable to access lob stream'

This is filter and Page object :

find by criteria : TournamentCriteria{}, page: Page request [number: 0, size 8, sort: startDate: DESC]

So it just gets 8 first tournaments.

This is tournament class :

@Entity
@Table(name = "tournament")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "tournament")
public class Tournament extends AbstractAuditingEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
    @SequenceGenerator(name = "sequenceGenerator")
    private Long id;

    @Column(name = "name")
    private String name;

    @Column(name = "location")
    private String location;

    @Column(name = "url")
    private String url;

    @Column(name = "start_date")
    private ZonedDateTime startDate;

    @Column(name = "end_date")
    private ZonedDateTime endDate;

    @Column(name = "entry_fee")
    private Double entryFee;

    @Column(name = "prize")
    private Double prize;

    @Column(name = "goods")
    private String goods;

    @Column(name = "favorite_rating")
    private Long favoriteRating;

    @Column(name = "participants_number")
    private Integer participantsNumber;

    @Column(name = "finished")
    private Boolean finished;

    @Column(name = "view_only")
    private Boolean viewOnly;

    @Column(name = "image")
    private String image;

    @Column(name = "description")
    private String description;

    @Column(name = "teams_applied")
    private String teamsApplied;

    @Lob
    @Column(name = "schedule")
    private String schedule;

    @Lob
    @Column(name = "prize_distribution")
    private String prizeDistribution;

    @Lob
    @Column(name = "contacts")
    private String contacts;

    @Lob
    @Column(name = "rules")
    private String rules;

    @OneToMany(mappedBy = "tournament", fetch = FetchType.LAZY)
    @JsonIgnore
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    private Set<Stream> streams = new HashSet<>();

    @ManyToMany(fetch = FetchType.EAGER)
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    @JoinTable(name = "tournament_platforms", joinColumns = @JoinColumn(name = "tournaments_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "platforms_id", referencedColumnName = "id"))
    private Set<Platform> platforms = new HashSet<>();

    @ManyToOne
    private Game game;

    @ManyToOne
    private TournamentStatus status;

    @ManyToOne(fetch = FetchType.LAZY)
    private EntryType entryType;

    @ManyToOne(fetch = FetchType.LAZY)
    private TournamentFormat format;

    @ManyToOne
    private Region region;

    @ManyToOne(fetch = FetchType.LAZY)
    private GameMode gameMode;

    @ManyToOne(fetch = FetchType.LAZY)
    private PrizeType prizeType;

    @ManyToOne
    private Organizer organizer;

    @ManyToOne(fetch = FetchType.LAZY)
    private TournamentStage stage;

    @ManyToOne
    private HostPlatform hostPlatforms;

    @ManyToOne(fetch = FetchType.LAZY)
    private TournamentType type;

    @ManyToOne
    private PlayType playType;

    @ManyToOne
    private Currency currency;

    @ManyToOne
    private Country country;

Here is the method that calls hibernate :

@Transactional(readOnly = true)
public Page<Tournament> findByCriteria(TournamentCriteria criteria, Pageable page) {
    log.info("find by criteria : {}, page: {}", criteria, page);
    final Specifications<Tournament> specification = createSpecification(criteria);
    Page<Tournament> result = tournamentRepository.findAll(specification, page);
    return result;
}

Upvotes: 0

Views: 1868

Answers (1)

ValerioMC
ValerioMC

Reputation: 3176

Is it possibile that you are trying to access Lob properties when hiberante session is closed?

Try to replace your @Lob properties with the following:

@Basic(fetch=FetchType.EAGER) @Lob

and check if the error persists.

Upvotes: 1

Related Questions