-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: “could not initialize a collection” + @Lob + MSSQL
PostPosted: Fri Aug 27, 2010 10:30 am 
Newbie

Joined: Fri Aug 27, 2010 10:08 am
Posts: 7
Hi.

The same question was asked here.

When using Blob-fields in n-to-m-relations Hibernate and MSSQL are failing for some reason.

Code:
SQL Error: 421, SQLState: S0001
The image data type cannot be selected as DISTINCT because it is not comparable.
...
could not initialize a collection: [Dataset.documents#someID]


My classes look as follows:

Code:
@Entity
class Dataset {
    @OneToMany(fetch = FetchType.LAZY)
    public List<Document> documents = new ArrayList<Document>();
}


Code:
@Entity
class Document {
    @Id
    public long id;

    @Lob
    public byte[] data;
}


Any ideas on this? I already tried using a Set or Document[] to avoid the errors. It seems that Hibernate always tries a distinct SELECT on my tables. How can I workaround this?

Thanks in advanced.

Jan


Top
 Profile  
 
 Post subject: Re: “could not initialize a collection” + @Lob + MSSQL
PostPosted: Fri Aug 27, 2010 10:46 am 
Newbie

Joined: Fri Aug 27, 2010 10:08 am
Posts: 7
I figured out that adding an inversed reference to my Doument class solves the problem. Is there a way to solve the problem without a ManyToOne-reference from Document to Dataset.
Code:
@Entity
class Dataset {
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "dataset")
    public List<Document> documents = new ArrayList<Document>();
}

Code:
@Entity
class Document {
    @Id
    public long id;

    @Lob
    public byte[] data;

    @ManyToOne
    @JoinColumn
    public Dataset dataset;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.