APISonar


javax.persistence.TemporalType.TIME

> javax > persistence > TemporalType > TIME
javax APIs persistence APIs TemporalType APIs TIME APIs

Example 1
public void testTimeWithCal() {
        GregorianCalendar cal = new GregorianCalendar(); 
        cal.set(1901, 11, 31, 23, 59, 59);
        cal.set(Calendar.MILLISECOND, 999);

        List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
            setParameter("time", cal, TemporalType.TIME).
            getResultList();
        
        assertTrue("There should be one result", result.size() == 1);
    }
Example 2
protected Object convertTemporalType(Object value, TemporalType type) {
        ConversionManager conversionManager = ((oracle.toplink.essentials.internal.sessions.AbstractSession)getEntityManager().getActiveSession()).getDatasourcePlatform().getConversionManager();
        if (type == TemporalType.TIME) {
            return conversionManager.convertObject(value, ClassConstants.TIME);
        } else if (type == TemporalType.TIMESTAMP) {
            return conversionManager.convertObject(value, ClassConstants.TIMESTAMP);
        } else if (type == TemporalType.DATE) {
            return conversionManager.convertObject(value, ClassConstants.SQLDATE);
        }
        return value;
    }