Okay, first: Thanx for reading this....
I noticed from another post here that there seems to be an issue with timestamps format mapping from java.util.date and java.sql.timestamp to database timestamps, but.... it seems i just dont get the point.
The case is i save a property of java type java.sql.timestamp which type is determined by reflection (i tried specifying it with type"java.sql.Timestamp" as well ....) it is saved perfectly, but no comparison i do in any HQL queries is doing what its supposed to.
I´m still a hibernate n00b and so the error could be in my hql query as well, but as far as ive seen in other posts it seems to be more a type-problem...
So what do i have to ?
Thanx for any advice...
Schokoladenhase
Hibernate version:
2.1.6
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
package="de.zolltek.gtc.data">
<class name="User" table="user">
<id name="id" type="string">
<column name="ID" not-null="true"/>
<generator class="uuid.hex"></generator>
</id>
<!-- DATA FIELDS -->
<property name="login" index="true"/>
<property name="password" index="true"/>
<property name="sprache"/>
<!-- FIELDS REQUIRED FOR HISTORIZABILISATION -->
<property name="recnum"/>
<property name="wer_in"/>
<property name="wer_out"/>
<property name="von"/>
<property name="bis"/>
<!-- RELATIONAL FIELDS -->
<!-- reflecting the 1:1 relation to person -->
<property name="personrecnum"/>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
package="de.zolltek.gtc.data">
<class name="Person" table="person">
<id name="id" type="string">
<column name="ID" not-null="true"/>
<generator class="uuid.hex"></generator>
</id>
<!-- DATA FIELDS -->
<property name="anrede"/>
<property name="email"/>
<property name="fax"/>
<property name="telefon"/>
<property name="vorname"/>
<property name="name"/>
<!-- FIELDS REQUIRED FOR HISTORIZABILISATION -->
<property name="recnum" not-null="true" index="rectime_idx"/>
<property name="wer_in"/>
<property name="wer_out"/>
<property name="von"/>
<property name="bis"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
person = (Person) s.createQuery("select p " +
"from Person p " +
"where p.recnum='"+personrecnum+"' "
+ServletContext.timeCriteria("")
)
.list()
.get(0);
....with ServletContext.timeCriteria("") being:
public static String timeCriteria(String activeuserrecnum) {
return new String(" and '"+getWishedTime(activeuserrecnum)+"' between " +
"bis and von");
}
public static Timestamp getWishedTime(String userrecnum) {
// TODO Make map with userwishedtimes
return new Timestamp(System.currentTimeMillis());
}
Full stack trace of any exception that occurs: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
10:38:44,090 INFO [STDOUT] at java.util.ArrayList.RangeCheck(ArrayList.java:507)
10:38:44,090 INFO [STDOUT] at java.util.ArrayList.get(ArrayList.java:324)
10:38:44,090 INFO [STDOUT] at de.zolltek.gtc.data.User.onLoad(User.java:225)
10:38:44,090 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.initializeEnti......
Name and version of the database you are using:MySQL 3.2.3
The generated SQL (show_sql=true):Code:
select user0_.ID as ID, user0_.login as login, user0_.password as password, user0_.sprache as sprache, user0_.recnum as recnum, user0_.wer_in as wer_in, user0_.wer_out as wer_out, user0_.von as von, user0_.bis as bis, user0_.personrecnum as personr10_ from user user0_ where (user0_.login='Max' )and(user0_.password='Moritz' )and(bis>'2004-12-17 10:38:43.609' )and(von<'2004-12-17 10:38:43.609' )
select person0_.ID as ID, person0_.anrede as anrede, person0_.email as email, person0_.fax as fax, person0_.telefon as telefon, person0_.vorname as vorname, person0_.name as name, person0_.recnum as recnum, person0_.wer_in as wer_in, person0_.wer_out as wer_out, person0_.von as von, person0_.bis as bis from person person0_ where (person0_.recnum='2c90a5ee00dc27380100dcaf72d401a7' )and(bis>'2004-12-17 10:38:44.009' )and(von<'2004-12-17 10:38:44.009' )