File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes How mapping xml column Hibernate from DB SQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How mapping xml column Hibernate from DB SQL Server" Watch "How mapping xml column Hibernate from DB SQL Server" New topic
Author

How mapping xml column Hibernate from DB SQL Server

Alfredo Hidalgo
Greenhorn

Joined: Aug 31, 2012
Posts: 1
Hi, I'm new here, maybe this topic shouldn't be here, but I don't know where ask and I need solve this question.

I have a table in SQL Server and I need mapping, but it has a xml column, then I don't know how do that.

My table:

TableXXX
ID (PK, int, not null)
Name (nvarchar(200), not null)
Data (XML, not null)


In HBM.XML:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" schema="Test.dbo"
namespace="Project.Domain.Test" assembly="Project.Domain.Test">
<class name="TableXXX" table="TableXXX">
<id name="ID" type="System.Int32" column="ID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="Name" type="System.String"/>
<property name="Data" column="Data" type=??? />
</class>
</hibernate-mapping>


In C# definition of table:
using System;
using System.Xml;

namespace Project.Domain.Test
{
public class TableXXX
{
public virtual Int32 ID { get; set; }
public virtual String Name { get; set; }
public virtual ??? Data { get; set; } }
}
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

In the future please UseCodeTags rather than bold and color for formatting code and configuration.

You will need to define your own UserType. Below is an example of this for Oracles XmlType column. Perhaps one is out there somewhere for SQL server already otherwise this serves as an example of how to do the same.

http://solecjj.blogspot.com/2011/02/hibernate-with-oracle-xmltype.html


[How To Ask Questions][Read before you PM me]
 
wood burning stoves
 
subject: How mapping xml column Hibernate from DB SQL Server
 
Similar Threads
Could not parse mapping document from resource PojoTestTable.hbm.xml
spring+hibernate: insert data into database(one to many)
Hibernate - Query Issues With Many-To-One Relationships
Hibernate problem: One-To-Many association
org.hibernate.exception.SQLGrammarException: could not execute query