-->
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: select generatedAlias0 from null
PostPosted: Thu Nov 03, 2011 12:13 am 
Newbie

Joined: Fri May 21, 2010 8:53 pm
Posts: 8
Hi. I'm using JPA annotations, EntityManager, and JPA metamodel to create typed queries. Note the from null part in the query below; I get a QuerySyntaxException due to the fact that my code is generating the following SQL/HQL/JP-QL (not sure which, but it's probably supposed to be one of the latter two):

Code:
select generatedAlias0 from null as generatedAlias0 where generatedAlias0.playerId=:param0]


This is the code I'm using to generate it:

Code:
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Player> criteriaQuery = criteriaBuilder.createQuery(Player.class);
Root<Player> root = criteriaQuery.from(Player.class);
Predicate condition = criteriaBuilder.equal(root.get(Player_.playerId), player.getPlayerId());
criteriaQuery.where(condition);
TypedQuery<Player> typedQuery = entityManager.createQuery(criteriaQuery);
Player result = typedQuery.getSingleResult();


Even when I put in the following line (though I'm not sure it's even necessary), nothing changes:

Code:
criteria.select( root );


Here is my entity:

Code:
@Entity
@Table(name = "players",
        uniqueConstraints = {@UniqueConstraint(columnNames={"playerId"})}
)
public class Player  implements java.io.Serializable {

    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @Column(nullable = false) private String fullName;
    @Column(nullable = false) private String playerId;
    private Date birthdate;
// more code here ...
}


Has anyone seen this sort of behavior before, and/or know what I need to do to fix it? Thanks very much!


Top
 Profile  
 
 Post subject: Re: select generatedAlias0 from null
PostPosted: Thu Nov 03, 2011 5:06 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2010 6:12 pm
Posts: 29
Possibly known issue:
https://hibernate.onjira.com/browse/HHH-6100


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.