-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unable to insert Date
PostPosted: Sat Jan 10, 2009 10:01 am 
Newbie

Joined: Tue Jan 06, 2009 5:03 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I have a class ResourceAllocation .I have written following hbm file for that class



<?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.nihilent.hrms.model.ResourceAllocation"
table="resourceallocation"
polymorphism="implicit"
dynamic-update="false"
dynamic-insert="true"
select-before-update="false"
optimistic-lock="version"
mutable="true"
>

<id
name="id"
column="Id"
type="java.lang.Integer"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-ResourceAllocation.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<set
name="requestedResourceAllocations"
lazy="false"
inverse="false"
cascade="save-update"
sort="unsorted"
>

<key
column="ResourceAllocationId"
>
</key>

<one-to-many
class="com.nihilent.hrms.model.RequestedResourceAllocation"
/>

</set>

<property
name="fromDate"
type="java.util.Date"
update="true"
insert="true"
column="FromDate"
length="10"
/>

<property
name="todate"
type="java.util.Date"
update="true"
insert="true"
column="ToDate"
length="10"
/>

<many-to-one
name="projectRoleMaster"
class="com.nihilent.hrms.model.ProjectRoleMaster"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="Role"
/>
</many-to-one>

<property
name="percentage"
type="java.lang.String"
update="true"
insert="true"
column="Percentage"
length="5"
/>

<property
name="createdOn"
type="java.util.Date"
update="true"
insert="true"
column="CreatedOn"
length="10"
/>

<property
name="createdBy"
type="java.lang.String"
update="true"
insert="true"
column="CreatedBy"
length="50"
/>

<property
name="modifiedOn"
type="java.util.Date"
update="true"
insert="true"
column="ModifiedOn"
length="10"
/>

<property
name="modifiedBy"
type="java.lang.String"
update="true"
insert="true"
column="ModifiedBy"
length="50"
/>

<property
name="status"
type="java.lang.String"
update="true"
insert="true"
column="Status"
length="15"
/>

<many-to-one
name="projectMaster"
class="com.nihilent.hrms.model.ProjectMaster"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="ProjectId"
/>
</many-to-one>

<many-to-one
name="associate"
class="com.nihilent.hrms.model.Associate"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="AssociateId"
/>
</many-to-one>

<many-to-one
name="resourceRequest"
class="com.nihilent.hrms.model.ResourceRequest"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="ResourceRequestId"
/>
</many-to-one>

<many-to-one
name="skillMaster"
class="com.nihilent.hrms.model.SkillMaster"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="SkillId"
/>
</many-to-one>

<many-to-one
name="planningType"
class="com.nihilent.hrms.model.ProjectPricingTypeMaster"
cascade="none"
outer-join="auto"
update="true"
insert="true"
>
<column
name="PlanningType"
length="100"
/>
</many-to-one>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ResourceAllocation.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>



This class consist four Date field . All are java.utill.Date.
At the time of inserting a new object when i pass
new Date() [/b] to modifiedOn or createdOn then it is ok .
But if i pass new Date() to fromDate or todate then on insert it beacame halt. I am using MS SQl Data base .
Can any one suggest what can be the problem


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 11, 2009 9:08 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
what error did you get?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2009 4:44 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Are the four database columns of the same type? If not, I suspect that may be the problem. With dates you may have to be more specific than saying that it is a java.util.Date. At the database level there are usually several types of date columns. Eg. timestamp, date with no time, date with time, time only, etc.


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

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.