[hibernate-dev] Inconsistent projection result

Marc Schipperheyn m.schipperheyn at gmail.com
Thu Feb 12 09:03:50 EST 2015


Projecting on an id is giving me inconsistent results.

On the same method, sometimes a String is returned, other times a Number.
I'm even seeing this difference running the test twice in a row.

I haven't been able to find what makes it switch, but I am 100% sure it
happens. I have this structure.

 List<Object[]> result = fts .createFullTextQuery( mj.createQuery(),
BaseWallPost.class) .setProjection(ProjectionConstants.ID, "post.id")
.list(); for(Object[] tuple : result){ // Long postId = tuple[1] != null?
Long.valueOf((String) tuple[1]) : null; Long postId = (Long) tuple[1]; }
@Entity public abstract class BaseComment{ @Id @GeneratedValue(strategy =
GenerationType.AUTO) @Column
@Field(name="longCommentId",index=Index.YES,store=Store.YES,analyze=Analyze.NO)
@DocumentId public Long id; } @Entity public abstract class BasePost
extends BaseComment{ @ManyToOne @JoinColumn
@IndexedEmbedded(includePaths={"id","type","longCommentId"},indexNullAs=Field.DEFAULT_NULL_TOKEN,includeEmbeddedObjectId=true)
@ContainedIn//Update the shareCount public Post post; } @Entity public
class Post extends BasePost{ } @Entity public class Comment extends
BaseComment{ @ManyToOne @JoinColumn
@IndexedEmbedded(includePaths={"id","type","blocked","longCommentId"},indexNullAs=Field.DEFAULT_NULL_TOKEN,includeEmbeddedObjectId=true)
@ContainedIn public BasePost post; }


More information about the hibernate-dev mailing list