Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.2.1
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.stufftolet.model.posting.CategoryVisitedStatistic"
table="category_visited_statistic"
>
<!-- Use of @hibernate.id for composite IDs is deprecated, use @hibernate.composite-id instead -->
<composite-id
name="compositeIdCategoryVisitedStatistic"
class="com.stufftolet.model.posting.CompositeIdCategoryVisitedStatistic"
>
<!-- Defining the key-property element from @hibernate.property tags is deprecated, use @hibernate.key-property instead -->
<key-property
name="visited"
type="java.util.Date"
column="visited"
>
</key-property>
<!-- Defining the key-many-to-one element from @hibernate.many-to-one tags is deprecated, use @hibernate.key-property instead -->
<key-many-to-one
name="category"
column="fk_category_id"
>
</key-many-to-one>
</composite-id>
<version
name="version"
column="version"
type="java.lang.Integer"
/>
</class>
</hibernate-mapping>
Name and version of the database you are using: mysql 5.0.27
Debug level Hibernate log excerpt:
Hi guys,
My CompositeIdCategoryVisitedStatistic is as follows:
package com.stufftolet.model.posting;
import java.io.Serializable;
import java.util.Date;
public class CompositeIdCategoryVisitedStatistic implements Serializable {
private Category category;
private Date visited;
public CompositeIdCategoryVisitedStatistic() {
}
public CompositeIdCategoryVisitedStatistic(Category category, Date visited) {
super();
this.category = category;
this.visited = visited;
}
/**
* @return Returns the categoryId.
* @hibernate.many-to-one cascade="save-update" column="fk_category_id"
*/
public Category getCategory() {
return category;
}
/**
* @return Returns the visited.
* @hibernate.property column="visited" not-null="true"
*/
public Date getVisited() {
return visited;
}
/**
* @param category the category to set
*/
public void setCategory(Category category) {
this.category = category;
}
/**
* @param visited the visited to set
*/
public void setVisited(Date visited) {
this.visited = visited;
}
public boolean equals(Object o) {
if (o instanceof CompositeIdCategoryVisitedStatistic) {
CompositeIdCategoryVisitedStatistic that = (CompositeIdCategoryVisitedStatistic) o;
return this.category.equals(that.category)
&& this.visited.equals(that.visited);
} else {
return false;
}
}
public int hashCode() {
return category.hashCode() + visited.hashCode();
}
}
I just want the field version to increment 1 point everytime I update the row with all the field's value remain the same. The problem is after updating, the field is not incremented. pls help.....
Thanks !