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.  [ 8 posts ] 
Author Message
 Post subject: Have troubles maping db column with type: XML. Please help
PostPosted: Wed Jun 18, 2008 11:33 am 
Newbie

Joined: Wed Jun 18, 2008 10:17 am
Posts: 5
Hibernate version: 2.0 or 1.2
Mapping documents: any
Name and version of the database you are using:MS SQL 2005


Can anybody give working sample for NHibernate of any version in C# about how to map database table witch contain filed with type: XML?


All my tries were unsuccesfull :(

I'm using files generated by NHibernate Plugin for VS2005.
Hirst of all NHibernate Plugin incorrect recocnize type of db field (System.Int32 instead System.Xml.XmlDocument).

When i trying to map this field by myself it courses a lot of exceptions.

Please help who know how to work with this kind of fields with type XML.
Thanks.
Quote:
Here is table i'm working with:

CREATE TABLE [dbo].[PluginsNew](
[PluginID] [int] NOT NULL,
[PluginDataXML] [xml](CONTENT [dbo].[WorkCyclus_PludinsXSD]) NULL,
CONSTRAINT [PK_PluginsNew] PRIMARY KEY CLUSTERED


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 1:16 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Have a look here:

http://www.hibernate.org/368.html

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 4:07 am 
Newbie

Joined: Wed Jun 18, 2008 10:17 am
Posts: 5
2 wolli :
Thank You for Your answer, but it was not helpful for me.
I have been implemented this solution with NHibernate version 2.0
And have no success.

I get following exception at
Code:
NHibernate.ISession GetCurrentSession()
:
"Could not determine type for: sdf.Persist.Hibernate.XmlDataType, for columns: NHibernate.Mapping.Column(PluginDataXML)"

Here is StackTrace:

Code:
"   at DAL.Helper.GetCurrentSession()\r\n   at DAL.EntytyFactory.GetAllPlugins() in C:\\Development\\NHibernate2Test\\DAL\\EntytyFactory.cs:line 13\r\n   at NHibernate2Test._Default.Page_Load(Object sender, EventArgs e) in C:\\Development\\NHibernate2Test\\NHibernate2Test\\Default.aspx.cs:line 21\r\n   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)\r\n   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)\r\n   at System.Web.UI.Control.OnLoad(EventArgs e)\r\n   at System.Web.UI.Control.LoadRecursive()\r\n   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)"



Can some one please help me with this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 4:17 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Have you specified the assembly in the type attribute:

Code:
type="sdf.Persist.Hibernate.XmlDataType, sdf"

or whatever your assembly name is ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 4:26 am 
Newbie

Joined: Wed Jun 18, 2008 10:17 am
Posts: 5
Yes in XML mapping file. I did this.

Here is XML:
Code:
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
  <class name="DAL.Plugin, DAL" table="PluginsNew">
    <id name="PluginID" type="System.Int32" column="PluginID" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="PluginDataXML" type="sdf.Persist.Hibernate.XmlDataType, sdf" column="PluginDataXML" not-null="false" />
  </class>
</hibernate-mapping>



Here is class:
Code:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace DAL {
   
   
    [System.SerializableAttribute()]
    public class AbstractPlugin {
       
        private int pluginID;
       
        private sdf.Persist.Hibernate.XmlDataType pluginDataXML;
       
        public virtual int PluginID {
            get {
                return this.pluginID;
            }
            set {
                this.pluginID = value;
            }
        }
       
        public virtual sdf.Persist.Hibernate.XmlDataType PluginDataXML {
            get {
                return this.pluginDataXML;
            }
            set {
                this.pluginDataXML = value;
            }
        }
    }
   
    [System.SerializableAttribute()]
    public partial class Plugin : AbstractPlugin {
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 4:37 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Have you added the sdf assembly to the hibernate configuration before creating the session factory. I'm not sure, but maybe that's necessary for nhib to recognize the type, even if there are no mapping files in that assembly.

If that's not the problem, Im' sorry, I can't give you any more help on this.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 4:45 am 
Newbie

Joined: Wed Jun 18, 2008 10:17 am
Posts: 5
Nope..stil not working. Same exception.
Here is hibernate.cfg.xml:

Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Server=***;initial catalog=WorkCyclus_A;User Id=***;Password=***;</property>
    <property name="show_sql">false</property>
    <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
    <property name="use_outer_join">true</property>
    <mapping assembly="DAL" />
    <mapping assembly="XMLAdaptationType"/>
  </session-factory>
</hibernate-configuration>



May be there is another solution. Please help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 10:14 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Did you try this solution with NHibernate 1.2.1? I tried to use a custom version type with NHibernate 2 with no luck - in Nhibernate 1.2.1 it works fine...
Perhaps a bug in NHibernate 2 or a mysterious breaking change I couldn't figure out...


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