I'm using the java class :
Code:
public class User {
private int id;
private String login;
private String password;
private String comments;
private int profil;
private String created;
private int logout_time;
private String lastPage;
private String timezone;
private int organisation;
private Identity identity;
// ... constructor, getters and setters
}
The mapping file I use :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="User" table="members">
<id name="id" type="int" unsaved-value="null">
<column name="id" not-null="true"/>
<generator class="native"/>
</id>
<property name="comments" column="comments" />
<property name="created" column="created"/>
<property name="lastPage" column="last_page"/>
<property name="login" column="login"/>
<property name="logout_time" column="logout_time"/>
<property name="password" column="password"/>
<property name="profil" column="profil"/>
<property name="timezone" column="timezone"/>
<component name="identity" class="org.jcollab.metier.Identity">
<property name="name" column="name"/>
<property name="title" column="title"/>
<property name="emailWork" column="email_work"/>
<property name="emailHome" column="email_home"/>
<property name="phoneWork" column="phone_work"/>
<property name="phone_Home" column="phone_home"/>
<property name="mobile" column="mobile"/>
<property name="fax" column="fax"/>
</component>
<property name="organisation" column="organization"/>
</class>
</hibernate-mapping>
The query I use : "from User".
This query give me all the rows of my table.
I would like to use java.util.Date for the "created" attribute. In my database, the sql type tha I use is VARCHAR(16) and not TIMESTAMP.
Here is the SQL code for creating the table :
Code:
CREATE TABLE `members` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`organization` mediumint(8) unsigned NOT NULL default '0',
`login` varchar(155) default NULL,
`password` varchar(155) default NULL,
`name` varchar(155) default NULL,
`title` varchar(155) default NULL,
`email_work` varchar(155) default NULL,
`email_home` varchar(155) default NULL,
`phone_work` varchar(155) default NULL,
`phone_home` varchar(155) default NULL,
`mobile` varchar(155) default NULL,
`fax` varchar(155) default NULL,
`comments` text,
`profil` char(1) NOT NULL default '',
`created` varchar(16) default NULL,
`logout_time` mediumint(8) unsigned NOT NULL default '0',
`last_page` varchar(255) default NULL,
`timezone` char(3) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;