emmanuel wrote:
what is the SQL query generated?
...Well, I have j2ee application: Informix DB - JBoss 4.0.4 AS - Swing Cilent, EJB3. SQL query is in class below:
Code:
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
@Entity
@Table(name = "my_table")
public class MyQuery implements Serializable
{
private Date endDate;
private String name;
private MyQuery parId;
private Set<MyQuery> childs;
public MyQuery()
{
childs = new HashSet<MyQuery>();
}
@ManyToOne
@JoinColumn(name = "par_id")
public MyQuery getParId()
{
return parId;
}
public void setParId(MyQuery parId)
{
this.parId = parId;
}
@Column(name = "full_name")
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Date getEndDate()
{
return endDate;
}
public void setEndDate(Date endDate)
{
this.endDate = endDate;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "parId")
@OrderBy("code ASC")
@Where(clause = "enddate >= today")
public Set<MyQuery> getChilds()
{
return childs;
}
public void setChilds(Set<MyQuery> childs)
{
this.childs = childs;
}
}
I need to get the field Set<MyQuery> childs where "enddate >= today".
I can get it if I create DB function(my_function) returns today in the following way:
Code:
@Where(clause = "enddate >= my_function()")
In this case Hibernate + Informix recognized my_function() as a function and executed that SQL query.
How to call system DB function in annotation?