-->
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: Problem with SQL SERVER 2005 uniqueidentifier mapping.
PostPosted: Mon Oct 05, 2009 2:14 pm 
Newbie

Joined: Mon Oct 05, 2009 1:58 pm
Posts: 1
Hello guys, I am a newbie in Hibernate.
Currently I am facing with such problem:

I have such bean:

public class DbInstance {

private String name = null;

private String guid = null;

public DbInstance() {
}

public DbInstance(String name) {
this.name = name;
}

public String getGuid() {
return guid;
}

public void setGuid(String guid) {
this.guid = guid;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return "DbInstance [name=" + name + "]";
}

}

mapping:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="***">
<class name="DbInstance" table="Admin_DatabaseInstance">
<id name="guid" column="DatabaseInstanceId">
<generator class="guid"/>
</id>
<property name="name" />
</class>
</hibernate-mapping>

I want to map mentioned class to already existed table in data base.
I can't modify schema of the database.

Table script:

USE [CMTAdmin]
GO
/****** Object: Table [dbo].[Admin_DatabaseInstance] Script Date: 10/05/2009 14:24:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Admin_DatabaseInstance](
[DatabaseInstanceId] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[InstancePreferences] [ntext] NOT NULL,
[PublisherInsName] [ntext] NULL,
[PublisherAdminInsName] [ntext] NULL,
CONSTRAINT [PK_DatabaseInstance] PRIMARY KEY CLUSTERED
(
[DatabaseInstanceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


The problem is, when I try to get all records of the DbInstance (for this I have created simple DAO class) I get an exception:

Initial SessionFactory creation failed.org.hibernate.HibernateException: Wrong column type in CMTAdmin.dbo.Admin_DatabaseInstance for column DatabaseInstanceId. Found: uniqueidentifier, expected: varchar(255)

So, there is a problem in mapping of SQL SERVER 2005 uniqueidentifier data type to Java String.
Also tried to use UUID -- outcome is the same.

I need a tip - what could be wrong in this situation, any help will be appreciated.
Thanks a lot.


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.