-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: how to increment the field vwith hibernate versioning
PostPosted: Wed Jan 17, 2007 2:55 pm 
Newbie

Joined: Sun Mar 05, 2006 12:43 pm
Posts: 5
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 !


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.