Null Date and Time Problem

I created my entity classes from a database by using netbeans 6.0 and I'm using H2 as a database. I've the following table in my database.
CREATE CACHED TABLE OPEN_TABLE ( ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY, TABLE_ID INTEGER, WAITER_ID INTEGER, OPEN_HOUR TIME DEFAULT CURRENT_TIME, OPEN_DATE DATE DEFAULT CURRENT_DATE );
and here is the entity class netbeans created for me.
import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * * @author Yupp */ @Entity @Table(name = "OPEN_TABLE") @NamedQueries({@NamedQuery(name = "OpenTable.findById", query = "SELECT o FROM OpenTable o WHERE o.id = :id"), @NamedQuery(name = "OpenTable.findByTableId", query = "SELECT o FROM OpenTable o WHERE o.tableId = :tableId"), @NamedQuery(name = "OpenTable.findByWaiterId", query = "SELECT o FROM OpenTable o WHERE o.waiterId = :waiterId"), @NamedQuery(name = "OpenTable.findByOpenHour", query = "SELECT o FROM OpenTable o WHERE o.openHour = :openHour"), @NamedQuery(name = "OpenTable.findByOpenDate", query = "SELECT o FROM OpenTable o WHERE o.openDate = :openDate")}) public class OpenTable implements Serializable {     private static final long serialVersionUID = 1L;     @Id     @Column(name = "ID", nullable = false)     private Integer id;     @Column(name = "TABLE_ID")     private Integer tableId;     @Column(name = "WAITER_ID")     private Integer waiterId;     @Column(name = "OPEN_HOUR")     @Temporal(TemporalType.TIME)     private Date openHour;     @Column(name = "OPEN_DATE")     @Temporal(TemporalType.DATE)     private Date openDate;     public OpenTable() {     }     public OpenTable(Integer id) {         this.id = id;     }     public OpenTable(Integer id, Date openHour, Date openDate) {         this.id = id;         this.openHour = openHour;         this.openDate = openDate;     }     public Integer getId() {         return id;     }     public void setId(Integer id) {         this.id = id;     }     public Integer getTableId() {         return tableId;     }     public void setTableId(Integer tableId) {         this.tableId = tableId;     }     public Integer getWaiterId() {         return waiterId;     }     public void setWaiterId(Integer waiterId) {         this.waiterId = waiterId;     }     public Date getOpenHour() {         return openHour;     }     public void setOpenHour(Date openHour) {         this.openHour = openHour;     }     public Date getOpenDate() {         return openDate;     }     public void setOpenDate(Date openDate) {         this.openDate = openDate;     }     @Override     public int hashCode() {         int hash = 0;         hash += (id != null ? id.hashCode() : 0);         return hash;     }     @Override     public boolean equals(Object object) {         // TODO: Warning - this method won't work in the case the id fields are not set         if (!(object instanceof OpenTable)) {             return false;         }         OpenTable other = (OpenTable) object;         if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {             return false;         }         return true;     }     @Override     public String toString() {         return "OpenTable[id=" + id + "]";     } }
The problem is when I try to insert a new OpenTable to the database, Open_Date and Open_Hour columns stay as null. I want them to get the automatic CURRENT_DATE and CURRENT_TIME values. I can't see where the problem is because I used CURRENT_DATE and CURRENT_TIME words when I created the table. I don't have any problems when I use standart SQL statements to insert a new row. I just use INSERT INTO OPEN_TABLE(TABLE_ID, WAITER_ID) VALUES(2,3) and get current date and hour values automatically but JPA doesn't do that for me. What should I do to solve the problem?

Those database defaults are only applied when you use an INSERT statement that specifies a list of columns excluding the ones with defaults. Presumably your persistence code always sets all columns when it does an INSERT, so the defaults won't apply. You'll have to find the way to set the defaults in the persistence layer, not in the database.

Similar Messages

  • Date and time problems

    On my older imacG5 running tiger I am able to display the clock as a floating transparent icon on the desktop which shows the date and time,
    on my newer intel imac and macbook pro running leopard I cannot do this, in fact there's two things that I can't do with leopard;
    1. I can't get the date displayed in the menu bar even when clicking show date and time in menu bar (only shows day of the week and time, but not the date)
    2. I can't get any clock to be displayed on the desktop? it's either in the menu bar or not at all.
    am I missing something or has Apple taken this feature away?
    (surely this isn't progress??)
    What's different in the two OS's is this:
    In Tiger date and time System Prefs there is a View In "Window" or "Menu Bar" option
    (selecting Window put s the clock on the desktop)
    as well as a sliding transperancy button which makes the clock see thro
    neither of these options are available in Leopard, so!!
    Is there a way to import the clock from the older machine/OSX?
    cheers

    Forgot to add when the time changes on its own, the time zone also changes to New York. I originaly set it to Montreal.

  • Enter Date and Time Problems

    When the entering the date or time in application like contacts birthday  etc...  the date button icons are all on top of each other and pressing the icon only brings up the year field.  The time is the same issue, all time button icons are on top of each other and only the am/pm field can be entered.   Got any suggestions?
    Post relates to: Pixi p120eww (Sprint)

    Hello K_Johanson and welcome to the Palm forums.
    I'm running webOS 1.4.5 on my Sprint Pre and I'm not seeing this issue when I try to enter a date for a birthday in Contacts.
    Have you tried restarting your phone?  Do you have the problem if you create a new Contacts record?
    Alan G

  • Problem with date and time preference

    hi there,
    i set my date and time and the time support yesterday and then i click the lock button to prevent further chance and last night i shut down my iMac, open it again in the morning the lock open back up and the timezone support change.
    i redo that again and restart my iMac the same thing happen. is this a problem with my software or everyone have this problem?
    any idea what should i do?
    thanks in advance
    regards AL

    Having the same problem, & am running Parallels (which I haven't used for some time) not boot camp. I tick the box labeled "Set time automatically" & lock the "click the lock to make changes". When I reboot, the Lock is unlocked and the "set time...." is unticked. Any ideas. Cheers.

  • Problem with date and time syncing itouch to macbook

    i have a problem with the date and time on ical when i sync my itouch4 w my macbookair. whatever i entered into my calendar in itouch will appear different in my ical( with a 6 hrs advance difference) and the alarm i set on my itouch in the calendar doesnt ring at the right time as set even though it is shown the time that i wanted.
    Both my macbook n itouch are set to the same time zone and i have checked this many many times n the time is the same on both machine. but i just dont understand why is there a time difference when synced and my alarm just dont sound at the time it was supposedly set. it rings hours later n showing a different time that it was set but in the parenthesis the right time that i had set it.
    One time my computer ran out of battery n went into sleep mode and when i open it again, the time n date setting was all off. which im surprised why it had gone off. So did this create the problem i have now with the date n time sync or something else?
    please help!!!!

    Having the same problem, & am running Parallels (which I haven't used for some time) not boot camp. I tick the box labeled "Set time automatically" & lock the "click the lock to make changes". When I reboot, the Lock is unlocked and the "set time...." is unticked. Any ideas. Cheers.

  • Please help , I have iPhone 4S and have updated to iso6, don't know if that has anything to do with the problem but I can't set the year on date and time to the correct year, it automatically goes to 2578 ? Plz help

    Subject:
    Please help , I have iPhone 4S and have updated to iso6, don't know if that has anything to do with the problem but I can't set the year on date and time to the correct year, it automatically goes to 2578 ? Plz help

    Settings>General>International.
    Set the calendar to "Gregorian". You have it set to Buddhist.

  • From yesterday, I have been facing the problems in my iphone and my wife iphone. The same problem, "cannot connect to itunes store". I have strong internet connection. I tried all the possible way I could like setting, general, date and time.....etc.

    I have proble of "cannot connect to itunes store. After I have updated the new software ios6, the problem arised in one of my mobile. In the second mobile, I didnot updated the software.Today in the morning, the problem ariesed in that mobile as well. I cannot open the itunes, don't have access to apple store . I tried to solve the problem like going to setting, general, Date and time, automatically off, keeping one year ahead date. I tried all the possible options I could get from the googel. How do I get rid of this problem?

    No - I have not tried other routers on my network.
    What I meant was I could use my itouch on other users wireless networks without any issues.
    I'll update the routers DNS to try  using Google's 8.8.8.8 instead of my ISP.
    Is the issue DNS performance using local ISP -or are there other possibel isues when using local isp DNS?

  • Changing date and time is wrong with time zone problem

    Okay, searched some of the forums, but didn't get the most correct answer to this:
    I just imported all my photos into Aperture from iPhoto (chose to have Aperture manage files as I don't plan on using iPhoto any longer. When I imported the files, I decided to do some organizing by date into folders. no problem.
    In some of my projects, I found some files that I imported from scans or got from others who had a film roll and processed it at a lab, and the dates from those files aren't the dates that the event took place. I went into Metadata>Adjust date and time, and changed the date (not so much the time I'm worried about), and checked the "change the masters" little box, too.
    After I close out of that box, the picture has the wrong date. I've determined this is because of the time zone support. I currently live in Japan, and I would like my photos here to show up as the date in the place they were taken. I think the date I enter, it thinks is the date I'm currently in (GMT +9), but aperture chooses to convert the date as if I was saying "hey, the picture I took happened on "date" in GMT +0:00)" which then makes it look in the metadata view as if it happened a day earlier.
    Any imported photos come in as the correct date and time and correct time zone, as far as I can see. It's just when I change the date and time it thinks I mean to have aperture convert it to GMT + 0:00. (but on a little more of a funny side... older pictures that happened in other time zones back in the states it lists the correct date and time for when the picture was taken, but "says" it's GMT +9:00) (another issue I'll deal with later maybe!)
    Hope I've described it in such a way that you can get it.

    I changed time and now my MacBook won't work

  • Having problem with the apple tv, because it still setting date and time and dont finish w the activation

    having problem with the apple tv, because it still setting date and time and dont finish w the activation

    That means it is having trouble connecting to the network. Make sure location is set correctly. Go to settings - general - network and ensure DNS is set to automatic. Check that your router is up to date. If on wifi try Ethernet.

  • Email syncs now say "Updated Mar 30", the day I upgraded to Lollipop 5.0.  The notification should read the date and time you updated email receiving.  Does anyone elsehave this problem?

    Email syncs now say "Updated Mar 30", the day I upgraded to Lollipop 5.0.  Two days later it is still saying Mar 30.  The notification should read the date and time you updated email receiving.  Does anyone else have this problem?  Is there a solution to this?

    We want to make sure your phone is in working order Mb_in_NC. I know it can be difficult when you see different times. What is your make/model of your device? When did it start? Do you have a different time on any other applications?
    AmberF_VZW
    Follow us on Twitter @VZWSupport
    If my response answered your question please click the "Correct Answer" button under my response. This ensures others can benefit from our conversation. Thanks in advance for your help with this!!

  • Time, date and settings problems with boot camp

    I have recently installed Windows XP using boot camp on my macbook, and everything seemed to be working fine for a while. However, after a couple of weeks, i am now getting date and time errors every time i shut down Windows and boot back into Mac OS. Upon restart the date always resets it self to December 2000, and this causes multiple programs to stop working. Also, airport forgets my wireless settings and no longer connects to my base station until i re-enter the passwords, so the date wont correct itself using the internet. The only way i have been able to set the correct time and date is to either set it manually, or to use the ethernet cable as it requires no passwords, which is inconvenient as my base station is in a awkward place.
    After resetting the time, date and internet settings, my macbook works perfectly again until the next time i use boot camp. I have also had exactly the same problem with another macbook i have, and cannot figure out how to stop this from happening.

    FAT32 will accessible from both Windows and OS X
    If you don't want to reformat your ext drive you need something like http://www.paragon-software.com/home/hfs-windows/ or http://www.mediafour.com/products/macdrive/

  • I hav som problem with my appstore n ibook dey just dont load i thought i need 2 upi date but now in mavericks updates r connected with appstore it opens up but it doesnt load sam with my ibook app and ye my date and time is fine any solutions?

    i have some problem with my appstore and ibook they just dont load thought i need to update but now in mavericks updates are now connected with appstore so i cant do that it opens up but doesnt load just blank same with ibook store it says cannot connect and yea my date and time is fine any solutions?

    Hi, James.
    Yes, the iBook should run even with no battery installed.
    These are the four most common possibilities when the battery will not charge:
    (1) there is something wrong with your battery
    (2) there is something wrong with your power adapter
    (3) there is something wrong with your power input board (the part that contains the port where you plug in the adapter)
    (4) there is something wrong with your logic board
    Since you have eliminated all the possibilities except (4), it is likely that your logic board is having problems. The PMU (Power Management Unit) is part of the logic board, and it may be going out (hence, temporarily working again when you reset it). Since the iBook is not running reliably without the battery in place (as it should), replacing the battery most likely would be futile.
    When a computer gets to be five years old, it seems a bit short-sighted to pay very much for repairs, just to have something else go wrong sooner rather than later. Have you had a look at the hugely improved specs on the new MacBooks? Is it time for a new portable to avoid embarrassment during your presentations? It sounds like that could be your best option.

  • Problem with getting current date and time using oracle.jbo.domain.Date

    I`d like to get current date and time using oracle.jbo.domain.Date method getCurrentDate(), but it always return current date and 12:00:00. I also need to get the current time.

    I think you should use java.sql.Timestamp domain.
    (And set database type to TIME or DATETIME.)
    Jan

  • Keychain problem and "Set date and time automatically"

    Something very strange appened to me today. I spent a few hours to get it through.
    All starts when I decided to open System Preferences and *set date and time manually* (I lost date and time because I left my PowerBook without its battery for an hour). At the next login, Leopard was no more able to access keychain's stored passwords, even if all items on Keychain Access were right there. Everytime I tried to read one item's password, a pop-up window reminded me that I had not the right to do it. As soon as I set back "date and time" on automatic (time.euro.apple.com - for me) all became normal (all iCal reminders appeared at on time) and all services started to get their passwords from the stored list.
    Sorry for my English (I'm from Italy).
    Someone got the same issue?

    That looks like the correct IP address for the Apple NTP. Not sure why your AEBS is not getting the time stamp.
    Would you mind double-checking the following setting, using the AirPort Admin Utility?
    AirPort Tab - Base Station Options: Logging/NTP
    - Set Date & Time Automatically: time.apple.com (checked)
    Is it possible that you have UDP blocked on port 123? Is your AEBS connected to another Internet router?

  • LR2 File naming on import problem, date and time not from photo

    Hi all,
    I think I've run into a bug or inconsistency regarding the file naming in LR2. All my photos are named after the template YYYYMMDD-HHMMSS-XXXX.dng, where XXXX is the original file ID number and the rest is the capture date and time. This has worked excellently in 1.1 through 1.4.1.
    In LR2 this template, on import, doesn't use the capture time from the photo for naming but rather the _current_ time when the import happens. In the template editor you don't get to choose what time to apply, as the fields are simply called "Minute", "Second", etc.
    If I, however, use the function Library > Rename photos... on the new batch of photos after import, and apply the exact same template, they are correctly renamed to match their capture date.
    This is with LR 2.0 on Mac OS X 10.5.4 on PowerPC. Anyone else see the same thing?

    This is a reported bug.

Maybe you are looking for