-->
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: Could nor compile Mapping with JetDriver
PostPosted: Tue Dec 09, 2008 3:30 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 7:27 am
Posts: 26
Location: Germany
Hello Forum,
I try to create a MS-Access-Database with NHibernate.
My Mappings and the configuration runs perfect with SQL-CE but whe I try to do the same with the Jet-Driver I get the following fault:

"Could not compile the mapping document: Database.Mappings.FgBlocks.hbm.xml"

here is my mapping:
Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
  namespace="Database.Tables"
   assembly="Database" >
   <class
      name="FgBlocks"
      table="FgBlocks">
      <id
         name="Id">
         <generator
            class="guid" />
      </id>
      <property
         name="BlockName"
         length="255"
         not-null="true"
         unique="true" />
      <property
         name="FileName"
         length="255" />
      <property
         name="BlockType"
         not-null="true" />
   </class>
</hibernate-mapping>


whats wrong here?
I think the mapping file is ok.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 3:56 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Is there an inner exception with more information ? The mapping file looks ok for me. Maybe generator guid is not supported within Access/Jet-Driver.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 4:03 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 7:27 am
Posts: 26
Location: Germany
Hi wolli...

this is from my german output-window:

Eine Ausnahme (erste Chance) des Typs "System.IO.FileLoadException" ist in mscorlib.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "System.IO.FileLoadException" ist in NHibernate.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "NHibernate.HibernateException" ist in NHibernate.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "NHibernate.MappingException" ist in NHibernate.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "NHibernate.MappingException" ist in NHibernate.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "NHibernate.MappingException" ist in NHibernate.dll aufgetreten.

Oh, I see..:
"Could not load type NHibernate.JetDriver.JetDialect. Possible cause: no assembly name specified."
where do I have to specify it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 4:12 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Depending on the way you configure hibernate, something like this I would say:

<add
key="hibernate.dialect"
value="Namespace.For.Jet.Dialect.JetDialect, Assembly"
/>

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 4:19 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 7:27 am
Posts: 26
Location: Germany
Hmm...
I do it this way:

cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.JetDriver.JetDialect");


my whole configuration:
Code:
        private NHibernate.Cfg.Configuration ConfigureDatabase()
        {
            //http://nhibernate.sourceforge.net/NHibernateEg/NHibernateEg.Tutorial1A.html#NHibernateEg.Tutorial1A-Configuration


            // Enable the logging of NHibernate operations
            log4net.Config.XmlConfigurator.Configure();

            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
            cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionProvider,
                "NHibernate.Connection.DriverConnectionProvider");
            cfg.SetProperty(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass,
                "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
            switch (dbType)
            {
                case MSACCESS2003:
                    cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.JetDriver.JetDialect");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.JetDriver.JetDriver");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, ConnectionToDb);
                    //                        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _ConnectionToDb + ";User-Id=admin;Password=" + _Password + ";");
                    break;
                case MSACCESS2007:
                    cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.JetDriver.JetDialect");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.JetDriver.JetDriver");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, ConnectionToDb);
                    //                        "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + _ConnectionToDb + ";Jet OLEDB:Database Password=" + _Password + ";");
                    break;
                case MSSQL2008://MSSQL
                    cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.MsSql2000Dialect");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, ConnectionToDb);
                    break;
                case MSSQLCE:
                    cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.MsSqlCeDialect");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.SqlServerCeDriver");
                    cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionString, ConnectionToDb);
                    break;
            }

            cfg.AddAssembly("Database");
            MemoryStream stream = new MemoryStream();
            ////Ask NHibernate to use fields instead of Properties
            NHibernate.Mapping.Attributes.HbmSerializer.Default.Validate = true; //Enable Validation
            NHibernate.Mapping.Attributes.HbmSerializer.Default.HbmDefaultAccess = "_ConnectionToDb.camelcase-underscore";
            // Gather information from this assembly (can also be done class by class)
            NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(stream,
            System.Reflection.Assembly.GetExecutingAssembly());
            stream.Position = 0;

            cfg.AddInputStream(stream); // Send the Mapping information to NHibernate Configuration
            stream.Close();
            return cfg;
        }


Only SQL-CE and Access2003 are in progress at the moment...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 6:17 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Is the jet driver part of nhibernate.dll ? I thought that changed with 2.0 ? If it's not part, I would try:

cfg.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.JetDriver.JetDialect, Assembly");

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 6:33 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 7:27 am
Posts: 26
Location: Germany
Hmm...

this fault:

{"Could not instantiate dialect class NHibernate.JetDriver.JetDialect, NHibernate.JetDriver"}

The library calls NHibernate.JetDriver.

So Assembly I think has to be NHibernate.JetDriver, hasn't it?
The Name of my Assembly (DDT.PDMS) or the word "Assembly" also doesn't run.

tnx Carsten


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 6:44 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
"NHibernate.JetDriver.JetDialect, NHibernate.JetDriver" should be it, but if you still get the error than something different must be wrong ...


Maybe some of these posts here might help:

http://groups.google.com/group/nhusers/search?hl=en&group=nhusers&q=jetdriver&qt_g=Search+this+group

_________________
--Wolfgang


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.