facebook

Hibernate RE Error

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

    Douglas M Hurst
    Participant

    I’ve RE’d some Oracle Tables. Even in DB Explorer, two of the fields indicate Timestamp. But on the RE, all are set to String. One example of generated code is shown below. Those in bold/italics/underscore should be Timestamp, not String.

    /** minimal constructor */
    public Assignee(String assigneeLoginId, String assigneeFirstName,
    String assigneeLastName, String assigneePassword,
    String rowAddedOprid, String rowAddedDttm, String rowLastmantOprid,
    String rowLastmantDttm) {
    super(assigneeLoginId, assigneeFirstName, assigneeLastName,
    assigneePassword, rowAddedOprid, rowAddedDttm,
    rowLastmantOprid, rowLastmantDttm);

    Also, when I did this Assignee in isolation, it did generate Timestamps, but when done with a large group of tables, it consistently produces String vice Timestamp.

    Of course when I try to set the field, it takes a string, but I get an exception stating the month is invalid when I try to add a record at runtime.

    #302274 Reply

    support-joy
    Member

    douglasmhurst,

    To avoid of getting String type for Timestamp type fields, I would recommend you to do the following steps.

    1) Expand the tables which contains timestamp type field in 3rd wizard of Reverse Engineer.
    2) Select timestamp type field.
    3) Enter TIMESTAMP value for JDBC Type.
    4) Enter timestamp value for Hibernate Type.
    5) Repeat steps 2,3 and 4 for each timestamp type fields
    6) Click Finish

    I hope this works for you.

    #302305 Reply

    Douglas M Hurst
    Participant

    That works… sort of. I entered TIMESTAMP and timestamp on my two fields. What I’m seeing doesn’t look right.

    In assignee.hbm.xml I see

    <property name=”rowAddedDttm” type=”timestamp”>
    <column name=”ROW_ADDED_DTTM” not-null=”true” />
    </property>

    But in AbstractAssignee.java and Assignee.java I see old, depricated java.util.Date;

    /** minimal constructor */
    public Assignee(String assigneeLoginId, String assigneeFirstName,
    String assigneeLastName, String assigneePassword,
    String rowAddedOprid, Date rowAddedDttm, String rowLastmantOprid,
    Date rowLastmantDttm) {
    super(assigneeLoginId, assigneeFirstName, assigneeLastName,
    assigneePassword, rowAddedOprid, rowAddedDttm,
    rowLastmantOprid, rowLastmantDttm);

    …and in AssigneeDAO.java the fields are omitted altogether…

    private static final Log log = LogFactory.getLog(AssigneeDAO.class);
    // property constants
    public static final String ASSIGNEE_FIRST_NAME = “assigneeFirstName”;
    public static final String ASSIGNEE_LAST_NAME = “assigneeLastName”;
    public static final String ASSIGNEE_PASSWORD = “assigneePassword”;
    public static final String ASSIGNEE_PHONE = “assigneePhone”;
    public static final String ASSIGNEE_EMAIL = “assigneeEmail”;
    public static final String ROW_ADDED_OPRID = “rowAddedOprid”;
    public static final String ROW_LASTMANT_OPRID = “rowLastmantOprid”;

    Why would I put in TIMESTAMP and timestamp and have it generate java.util.Date?

    #302312 Reply

    Douglas M Hurst
    Participant

    @support-joy wrote:

    douglasmhurst,

    To avoid of getting String type for Timestamp type fields, I would recommend you to do the following steps.

    1) Expand the tables which contains timestamp type field in 3rd wizard of Reverse Engineer.
    2) Select timestamp type field.
    3) Enter TIMESTAMP value for JDBC Type.
    4) Enter timestamp value for Hibernate Type.
    5) Repeat steps 2,3 and 4 for each timestamp type fields
    6) Click Finish

    I hope this works for you.

    What I found worked better is TIMESTAMP and java.sql.Timestamp

    Also, you must delete all generated RE files or some will not RE with the new values.

    #302336 Reply

    support-joy
    Member

    What I found worked better is TIMESTAMP and java.sql.Timestamp

    Also, you must delete all generated RE files or some will not RE with the new values.

    Good to hear you are all set.Thanks for letting us know.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Hibernate RE Error

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