- This topic has 5 replies, 3 voices, and was last updated 20 years, 2 months ago by ylukekim.
-
AuthorPosts
-
ylukekimMemberHello,
Below are my developing environments.
-MyEcliseIDE 3.8.1GA
-Eclipse 3.0
-Oracle 9iThe description of the “activation” and “lastmodified” columns in the “mytable” table is as follows:
—–ORACLE SQL*PLUS—-
SQL> desc mytable
…
ACTIVATION NOT NULL NUMBER(1)
LASTMODIFIED NOT NULL TIMESTAMP(6)
…I followed the “hibernate” tutorial, in this website, step by step and MyEclipse generated the following mapping file.
—–Mytable.hbm.xml—-
…
<property name=”activation” column=”ACTIVATION” type=”java.lang.Byte” not-null=”true” />
<property name=”lastmodified” column=”LASTMODIFIED” type=”java.lang.String” not-null=”true” />
…Can the mapping file be like the following?
—– suggested mytable.hbm.xml—-
…
<property name=”activation” column=”ACTIVATION” type=”java.lang.Boolean” not-null=”true” />
<property name=”lastmodified” column=”LASTMODIFIED” type=”java.sql.Timestamp” not-null=”true” />
…Thank you very much.
Riyad KallaMemberI’ve sent the comments to the hibernate dev.
support-jeffMemberI am surprised the Timestamp did not get translated correctly, but the number to byte does not surprise me. Regardless, plans are afoot to make the translations more configurable. Probably won’t see this come til 3.9.
ylukekimMemberThank you so much for the action. In fact, I thought that the translation part was done not by Hibernate but by MyEclipse because of the existance of MyEclipse Database Explorer. But now I learn that it’s not…
For my work, I am going to modify both “Mytable.hbm.xml” and “AbstractMytable.java”. Below shows the two changes from the ORIGINAL to the NEW CODE. The changes are for each suggestion explained above. Please let me know if any (or both) of them has problems with MyEclipse (or Hibernate). I think CHANGE 1 will be ok because I read a post, in other websites, saying that the change never caused any problem. But I’m not sure about the second one. Please give me your kind advice if you know the answer.
CHANGE 1: This code change below is for the Timestamp correction. Will this work?
———- ORIGINAL —————————————–
<property name=”lastmodified” column=”LASTMODIFIED” type=”java.lang.String” not-null=”true” />
private java.lang.String lastmodified;
public java.lang.String getLastmodified() {
return this.lastmodified;
}
public void setLastmodified(java.lang.String lastmodified){
this.lastmodified = lastmodified;
}———- NEW CODE —————————————–
<property name=”lastmodified” column=”LASTMODIFIED” type=”java.sql.Timestamp” not-null=”true” />
private java.sql.Timestamp lastmodified;
public java.sql.Timestamp getLastmodified() {
return this.lastmodified;
}
public void setLastmodified(java.sql.Timestamp lastmodified){
this.lastmodified = lastmodified;
}CHANGE 2: This code change below is for the NUMBER(1) correction. Will this work?
———- ORIGINAL —————————————–
<property name=”activation” column=”ACTIVATION” type=”java.lang.Byte” not-null=”true” />
private java.lang.Byte activation;
public java.lang.Byte getActivation(){
return this.activation;
}
public void setActivation(java.lang.Byte activation){
this.activation = activation;
}———- NEW CODE —————————————–
<property name=”activation” column=”ACTIVATION” type=”java.lang.Boolean” not-null=”true” />
private java.lang.Boolean activation;
public java.lang.Boolean getActivation(){
return this.activation;
}
public void setActivation(java.lang.Boolean activation){
this.activation = activation;
}
support-jeffMemberBoth changes should work just fine. Proof is in the pudding, though: try them out and check the results (preferrably with some unit tests!). Just be aware that if you ever regenerate the mapping and classes with the ME tool, it will overwrite your changes.
ylukekimMemberThanks a lot!
-
AuthorPosts