List of usage examples for javax.persistence TemporalType DATE
TemporalType DATE
To view the source code for javax.persistence TemporalType DATE.
Click Source Link
java.sql.Date
From source file:edu.ku.brc.specify.datamodel.Attachment.java
@Temporal(TemporalType.DATE) @Column(name = "FileCreatedDate") public Calendar getFileCreatedDate() { return this.fileCreatedDate; }
From source file:com.expressui.core.util.BeanPropertyType.java
private BusinessType createBusinessType() { if (getType() == Date.class) { Temporal temporal = getAnnotation(Temporal.class); if (temporal != null && temporal.value().equals(TemporalType.DATE)) { return BusinessType.DATE; } else {/*from w w w . j a v a2 s. c o m*/ return BusinessType.DATE_TIME; } } if (ReflectionUtil.isNumberType(getType())) { return BusinessType.NUMBER; } if (String.class.isAssignableFrom(getType())) { return BusinessType.TEXT; } if (BigDecimal.class.isAssignableFrom(getType())) { return BusinessType.MONEY; } return null; }
From source file:myorg.relex.One2OneTest.java
/** * This test provides a demonstration of creating a one-to-one, uni-directional * relationship to a parent class that uses a composite primary key mapped thru an @IdClass *///from w w w .ja v a 2 s . c o m @Test public void testOne2OneUniIdClass() { log.info("*** testOne2OneUniIdClass ***"); Date showDate = new GregorianCalendar(1975 + new Random().nextInt(100), Calendar.JANUARY, 1).getTime(); Date showTime = new GregorianCalendar(0, 0, 0, 0, 0, 0).getTime(); ShowEvent show = new ShowEvent(showDate, showTime); show.setName("Rocky Horror"); ShowTickets tickets = new ShowTickets(show); //parent already has natural PK by this point tickets.setTicketsLeft(300); em.persist(show); em.persist(tickets); //flush commands to database, clear cache, and pull back new instance em.flush(); em.clear(); ShowTickets tickets2 = em.find(ShowTickets.class, new ShowEventPK(tickets.getDate(), tickets.getTime())); log.info("calling parent..."); assertEquals("unexpected name", tickets.getShow().getName(), tickets2.getShow().getName()); //verify the contents of the database tables, columns, and relationships Object[] cols = (Object[]) em.createNativeQuery("select show.date show_date, show.time show_time, " + "tickets.ticket_date ticket_date, tickets.ticket_time ticket_time, tickets.tickets " + "from RELATIONEX_SHOWEVENT show " + "join RELATIONEX_SHOWTICKETS tickets on show.date = tickets.ticket_date and show.time = tickets.ticket_time " + "where tickets.ticket_date = ?1 and tickets.ticket_time = ?2") .setParameter(1, tickets.getShow().getDate(), TemporalType.DATE) .setParameter(2, tickets.getShow().getTime(), TemporalType.TIME).getSingleResult(); log.info("row=" + Arrays.toString(cols)); assertEquals("unexpected show_date", tickets2.getShow().getDate(), (Date) cols[0]); assertEquals("unexpected show_time", tickets2.getShow().getTime(), (Date) cols[1]); assertEquals("unexpected ticket_date", tickets2.getDate(), (Date) cols[2]); assertEquals("unexpected ticket_time", tickets2.getTime(), (Date) cols[3]); assertEquals("unexpected ticketsLeft", tickets2.getTicketsLeft(), ((Number) cols[4]).intValue()); //remove the objects and flush commands to the database em.remove(tickets2); em.remove(tickets2.getShow()); em.flush(); assertNull("tickets not deleted", em.find(ShowEvent.class, new ShowEventPK(show.getDate(), show.getTime()))); assertNull("show not deleted", em.find(ShowTickets.class, new ShowEventPK(tickets.getDate(), tickets.getTime()))); }
From source file:com.medigy.persist.model.person.Person.java
@Basic(temporalType = TemporalType.DATE) @Column(name = "death_date") public Date getDeathDate() { return deathDate; }
From source file:fr.amapj.service.services.meslivraisons.MesLivraisonsService.java
/** * // ww w . j ava 2 s .c o m */ private List<ContratCell> getAllQte(EntityManager em, Date dateDebut, Date dateFin, Producteur producteur) { Query q = em.createQuery("select c from ContratCell c " + "WHERE c.modeleContratDate.dateLiv>=:deb AND " + "c.modeleContratDate.dateLiv<=:fin and " + "c.contrat.modeleContrat.producteur =:prod " + "order by c.modeleContratDate.dateLiv, c.contrat.modeleContrat.producteur.id, c.contrat.modeleContrat.id , c.modeleContratProduit.indx"); q.setParameter("deb", dateDebut, TemporalType.DATE); q.setParameter("fin", dateFin, TemporalType.DATE); q.setParameter("prod", producteur); List<ContratCell> prods = q.getResultList(); return prods; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopDateField.java
protected void initDateFormat(MetaProperty metaProperty) { TemporalType tt = null;//from w w w. jav a2 s . c om if (metaProperty.getRange().asDatatype().getJavaClass().equals(java.sql.Date.class)) { tt = TemporalType.DATE; } else if (metaProperty.getAnnotations() != null) { tt = (TemporalType) metaProperty.getAnnotations().get(MetadataTools.TEMPORAL_ANN_NAME); } setResolution(tt == TemporalType.DATE ? DateField.Resolution.DAY : Resolution.MIN); MessageTools messageTools = AppBeans.get(MessageTools.NAME); String formatStr = messageTools.getDefaultDateFormat(tt); setDateFormat(formatStr); }
From source file:edu.ku.brc.specify.datamodel.Preparation.java
/** * //from ww w. j av a2s. co m */ @Temporal(TemporalType.DATE) @Column(name = "PreparedDate", unique = false, nullable = true, insertable = true, updatable = true) public Calendar getPreparedDate() { return this.preparedDate; }
From source file:edu.ku.brc.specify.datamodel.Agent.java
/** * @return the dateOfBirth/* www. j ava2s . c om*/ */ @Temporal(TemporalType.DATE) @Column(name = "DateOfBirth", unique = false, nullable = true, insertable = true, updatable = true) public Calendar getDateOfBirth() { return dateOfBirth; }
From source file:org.openhie.openempi.model.Person.java
@Temporal(TemporalType.DATE) @Column(name = "date_of_birth", length = 4) @XmlElement public Date getDateOfBirth() { return this.dateOfBirth; }
From source file:edu.ku.brc.specify.datamodel.Agent.java
/** * @return the dateOfDeath/* ww w.ja v a2 s . c o m*/ */ @Temporal(TemporalType.DATE) @Column(name = "DateOfDeath", unique = false, nullable = true, insertable = true, updatable = true) public Calendar getDateOfDeath() { return dateOfDeath; }