[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6280) JPA criteria API don't bind numeric field

Strong Liu (JIRA) noreply at atlassian.com
Wed Feb 29 02:26:49 EST 2012


    [ https://hibernate.onjira.com/browse/HHH-6280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45741#comment-45741 ] 

Strong Liu commented on HHH-6280:
---------------------------------

https://issues.jboss.org/browse/JBPAPP-7198

> JPA criteria API don't bind numeric field
> -----------------------------------------
>
>                 Key: HHH-6280
>                 URL: https://hibernate.onjira.com/browse/HHH-6280
>             Project: Hibernate ORM
>          Issue Type: Improvement
>          Components: entity-manager
>    Affects Versions: 3.5.5
>            Reporter: gwa
>            Assignee: Steve Ebersole
>              Labels: jpa2
>
> When you use JPA criteria API, the numeric value are not binded but are directly set in the SQL instead. 
> eq: you have a generated SQL like:
> select ... from ... where age=12;
> instead of 
> select ... from ... where age=?;
> With '12' as parameter.  
> when you test the following code:
> {code:java}
> @Entity
> public class User {
> 	@Id
> 	private int id;
> 	private int age;
>         ...
> }
> {code}
> {code:java}
>     CriteriaBuilder builder=em.getCriteriaBuilder();
>     CriteriaQuery<User> query=builder.createQuery(User.class);
>     Root<User> root=query.from(User.class);
>     query.select(root).where(builder.equal(root.get("age"),12));
>     em.createQuery(query).getResultList();
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list