-->
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.  [ 2 posts ] 
Author Message
 Post subject: Error in inserting records using Hibernate for ROWID column
PostPosted: Sat Apr 13, 2013 9:18 am 
Newbie

Joined: Sat Apr 13, 2013 8:44 am
Posts: 1
Hi,

Not Able to insert records using Hibernate version: 2.0
and database SQL Server 2005 when ROWID is present in the table column.


Code:
CREATE TABLE [dbo].[C_CMTC] (
[I_CMTC] numeric(20, 0) NOT NULL,
[TTL_PRCS] numeric(20, 0) NULL,
[TTL_THRD] numeric(20, 0) NULL,
[ROWID] uniqueidentifier NOT NULL DEFAULT (newid()))
ON [PRIMARY];
GO


Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class name="com.farbeyond.server.dao.entities.C_CMTCImpl"
              table="C_CMTC">

        <id name="ixcmtc" type="long">
            <column name="I_CMTC" precision="20" scale="0" />
            <generator class="increment" />
        </id>
        <property name="ttlxprcs" type="long">
            <column name="TTL_PRCS" precision="20" scale="0" />
        </property>
        <property name="ttlxthrd" type="long">
            <column name="TTL_THRD" precision="20" scale="0" />
        </property>
        <property name="rowid" type="string"  >
            <column  name="ROWID" length="36" unique="true" />
           <generator class="native" />
        </property>

   </class>
</hibernate-mapping>


While insert the data from Hibernate we get the following Error.

EVERE: Error parsing XML: XML InputStream(23) The content of element type "property" must match "(meta*,(column|formula)*,type?)".
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/seeinfobiz/click/entitybean/Cxmxtxc.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at hibernateexample.Main.main(Main.java:26)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping


But if I insert record using the following query :

Code:
insert into dbo.C_CMTC (I_CMTC,TTL_PRCS,TTL_THRD)
values (3,4,3);


it inserts the records the desired records.

Any help would be greatly appreciated.


Best Regards,

Ashwini Kumar


Top
 Profile  
 
 Post subject: Re: Error in inserting records using Hibernate for ROWID column
PostPosted: Sat Apr 13, 2013 10:52 am 
Regular
Regular

Joined: Wed Apr 10, 2013 1:02 am
Posts: 50
Rowid is generated by database. You don't have to provide it in cfg

_________________
Regards
Akash Miital
http://akash.thegrassroots.co.in/hibernate/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.