mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-19 21:00:53 +08:00
Improve EclipseLink mappings
This commit is contained in:
parent
f0c1c44cc4
commit
d8337bfc26
@ -70,13 +70,19 @@ public class EclipseLinkTemplates extends JPQLTemplates {
|
||||
add(Ops.NUMCAST, "cast({0} {1s})");
|
||||
|
||||
// datetime
|
||||
add(Ops.DateTimeOps.MILLISECOND, "extract(microsecond from {0})");
|
||||
add(Ops.DateTimeOps.MILLISECOND, "extract(millisecond from {0})");
|
||||
add(Ops.DateTimeOps.SECOND, "extract(second from {0})");
|
||||
add(Ops.DateTimeOps.MINUTE, "extract(minute from {0})");
|
||||
add(Ops.DateTimeOps.HOUR, "extract(hour from {0})");
|
||||
add(Ops.DateTimeOps.DAY_OF_WEEK, "extract(day_of_week from {0})");
|
||||
add(Ops.DateTimeOps.DAY_OF_MONTH, "extract(day from {0})");
|
||||
add(Ops.DateTimeOps.DAY_OF_YEAR, "extract(day_of_year from {0})");
|
||||
add(Ops.DateTimeOps.WEEK, "extract(week from {0})");
|
||||
add(Ops.DateTimeOps.MONTH, "extract(month from {0})");
|
||||
add(Ops.DateTimeOps.YEAR, "extract(year from {0})");
|
||||
|
||||
add(Ops.DateTimeOps.YEAR_MONTH, "extract(year from {0}) * 100 + extract(month from {0})");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -479,6 +479,18 @@ public abstract class AbstractJPATest {
|
||||
assertEquals(1, query().from(cat).distinct().list(cat.birthdate).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Date() {
|
||||
query().from(cat).list(cat.birthdate.year());
|
||||
query().from(cat).list(cat.birthdate.yearMonth());
|
||||
query().from(cat).list(cat.birthdate.month());
|
||||
query().from(cat).list(cat.birthdate.week());
|
||||
query().from(cat).list(cat.birthdate.dayOfMonth());
|
||||
query().from(cat).list(cat.birthdate.hour());
|
||||
query().from(cat).list(cat.birthdate.minute());
|
||||
query().from(cat).list(cat.birthdate.second());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ExcludeIn(ORACLE)
|
||||
public void Divide() {
|
||||
@ -1469,3 +1481,4 @@ public abstract class AbstractJPATest {
|
||||
.list(animal.id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user