facebook

Temporal type generates hibernate exception

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #294937 Reply

    Scott Dunbar
    Participant

    I’m reverse engineering a Postgres 8.3 database. My column type is timestamp. When the code is generated from the reverse engineering it looks like:

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "last_update", nullable = false, length = 29)
    public Timestamp getLastUpdate() {
        return this.lastUpdate;
    }

    However, if I leave this code as is I get an exception from Hibernate:

    Caused by: org.hibernate.AnnotationException: @Temporal should be set on a java.util.Date or java.util.Calendar property: package.Company.createDate
        at org.hibernate.cfg.annotations.SimpleValueBinder.setType(SimpleValueBinder.java:93)
        at org.hibernate.cfg.annotations.PropertyBinder.bind(PropertyBinder.java:117)
        at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1581)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
    

    If I remove the @Temporal annotation the code works fine. Is this a Hibernate problem or a JPA problem?

    Thanks for any help.

    #294972 Reply

    Loyal Water
    Member

    stdunbar,
    The dev team is looking into this issue and they will get back to you with a reply asap.

    #296492 Reply

    bimki
    Member

    hi,
    did You solve this problem?

    #296498 Reply

    GritsMcgee
    Member

    I’m having the same issue reverse engineering a MySQL database. Column type is DATETIME, the reverse engineering is generating a java.sql.timestamp type but than also adding a TemporalType.TIMESTAMP annotation which is not needed.

    
        private Timestamp   crtDttm;
        private Timestamp   mdfyDttm;
    
    
    @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "CRT_DTTM", nullable = false, length = 19)
        public Timestamp getCrtDttm() {
            return this.crtDttm;
        }
    
    @Temporal(TemporalType.TIMESTAMP)
        @Column(name = "MDFY_DTTM", length = 19)
        public Timestamp getMdfyDttm() {
            return this.mdfyDttm;
        }
    
    
    #297411 Reply

    Hi,

    I ran into a severe problem while doing JPA reverse engineering from MySQL 5 to Java classes using MyEclispe Version: 7.1.

    Environment: MyEclipse Build id: 7.1-20090306, Java jdk1.5.0_14 and Tomcat 5.0.28.

    At runtime, the application is throwing the following exception:
    javax.persistence.PersistenceException: org.hibernate.AnnotationException: @Temporal should be set on a java.util.Date or java.util.Calendar property: com.sourcestio.reviewsframework.model.ReviewTemplate.creationDate

    The column in my table is as under:
    creation_date timestamp(8) not null,

    The generated code as the annonation as under:
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name=”creation_date”, nullable=false, length=19)

    So basically the code is adding an @Temporal annotation for TIMESTAMP, which is not allowed.

    By the way, this problem started after I updated from MyEclipse 6 to 7. With MyEclipse 6, the TemporalType was getting generated as DATE, which has it’s own set of problems:

    @Temporal(TemporalType.DATE)
    @Column(name=”creation_date”, unique=false, nullable=false, insertable=true, updatable=true, length=19)

    What’s happening with 7.1 is a big problem, because we have the creation_date and modification_date columns in every table.

    Are there any workarounds to suppress the TemporalType generation?

    If not, when can I expect this bug to be fixed?

    Thanks,
    Unmesh

    #297651 Reply

    MyEclipse Support,

    This bug seems to be open for a long time, yet for months there is no response apart from “The dev team is looking into this issue and they will get back to you with a reply asap.”.

    Can I expect a commitment fixing this sometime soon?

    Thank you,
    Unmesh

    #297835 Reply

    Brian Fernandes
    Moderator

    I have replicated this problem locally and we will be fixing this in the next release of MyEclipse, priority has been suitably raised. Unfortunately I cannot suggest a workaround for this problem at this point, I’m sorry you ran into this issue.

    #298829 Reply

    Brian Fernandes
    Moderator

    This problem has been fixed in 7.5M1, can you please try a sample reverse engineering pass in this version and let us know if you run into any issues? This will ensure we catch problems before the GA version is released in a few weeks.

    Thanks!

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Temporal type generates hibernate exception

You must be logged in to post in the forum log in