This content has been marked as final.
Show 2 replies
-
1. Re: do filtering by time range
lvdberg Sep 3, 2009 11:05 AM (in response to trunikov.dmitry.trunikov.zoral.com.ua)You could create a
criteria-bean
which contains the fields which you want to use. Look in the Seam doc chpter 13 on how to do that. You can use without a problem Date ranges, and - with some additional getters -a time range. -
2. Re: do filtering by time range
pdhaigh Sep 3, 2009 4:57 PM (in response to trunikov.dmitry.trunikov.zoral.com.ua)You can identify an example Entity:
@Name("expedition") @Role(name="exampleExpedition") public class Expedition implements Serializable
and then use it like this:
private static final String[] RESTRICTIONS = { "e.startDate > #{exampleExpedition.startDate}", "e.startDate < #{exampleExpedition.endDate}", };
You can also extend the Hibernate dialect to provide some date functions for you (example follows for InnoDB):
import org.hibernate.Hibernate; import org.hibernate.dialect.MySQLInnoDBDialect; import org.hibernate.dialect.function.SQLFunctionTemplate; public class ExtendedInnoDBDialect extends MySQLInnoDBDialect { public ExtendedInnoDBDialect() { super(); registerFunction( "date_sub_interval", new SQLFunctionTemplate( Hibernate.DATE, "date_sub(?1, INTERVAL ?2 ?3)" ) ); registerFunction( "date_add_interval", new SQLFunctionTemplate( Hibernate.DATE, "date_add(?1, INTERVAL ?2 ?3)" ) ); } }
This will then let you use EL restrictions such as:
dueDate<date_add_interval(#{constants.currentDate}, 1, WEEK)