Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » JPA CriteriaQuery MD5
JPA CriteriaQuery MD5 [message #1006338] Wed, 30 January 2013 16:41 Go to next message
Eclipse UserFriend
Greetings,

Could somebody help to translate similar native query text to CriteriaQueriy code?

select tmp from tbl  
(select * from db_emails where folder="spam") tmp
where tmp.digest=md5(concat("digest",?))


Thanks in advance,
Re: JPA CriteriaQuery MD5 [message #1007347 is a reply to message #1006338] Tue, 05 February 2013 10:30 Go to previous messageGo to next message
Eclipse UserFriend
This would probably be better as a native SQL query, as it is complex and data specific.

The Criteria API does not support sub-selects in the from clause, so you would need to reword the query. To call the MD5 function you can use the function() API in Criteria.

What is your object model?
Re: JPA CriteriaQuery MD5 [message #1007750 is a reply to message #1007347] Thu, 07 February 2013 07:04 Go to previous message
Eclipse UserFriend
Greetings Mr. Sutherland,
Thank you for you answer.
I use simplest object model here:
@Entity
@Table(name = "db_emails")
class Email implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "title")    
    private String title;
    @Column(name = "from")    
    private String from;
    @Column(name = "to")
    private String to;
    @Column(name = "content")    
    private String content;
    @Column(name = "digest")
    private String digest;
/*
Getters and setters are being declared here

*/

}


It looks I made misprint in topic start message. Query I'm rtying to make with CriteriaQueries is about quering same table twice
select tmp from db_emails  
(select * from db_emails where folder="spam") tmp
where tmp.digest=md5(concat("digest",?))



Thanks in advance,

[Updated on: Mon, 11 February 2013 13:53] by Moderator

Previous Topic:OutOfMemoryError from JTASynchronizationListener
Next Topic:eclipselink flush mode out of memory
Goto Forum:
  


Current Time: Wed Jul 16 06:14:01 EDT 2025

Powered by FUDForum. Page generated in 0.09700 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top