/* * NewMain.java * * Created on February 10, 2006, 7:25 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package testdate; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TemporalType; /** * * @author blaha */ public class NewMain { private static EntityManagerFactory emF = Persistence.createEntityManagerFactory("em"); private static EntityManager em = emF.createEntityManager(); /** Creates a new instance of NewMain */ public NewMain() { } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here EntityTransaction tx = em.getTransaction(); tx.begin(); Plan plan1 = new Plan(); plan1.setDeadLineDate(new Date()); plan1.setCreationTime(new GregorianCalendar()); em.persist(plan1); List plans = em.createQuery("SELECT a FROM Plan a WHERE a.creationTime <= :time AND a.deadLineDate = CURRENT_DATE"). setParameter("time", new GregorianCalendar(), TemporalType.TIME).getResultList(); for(Plan plan : plans) System.out.println(plan); tx.commit(); } }