AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

MYSQL + NHIBERNATE + CODESMITH #45

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
codesmith 5.0.1
mysql v 6 and version 5.x
database layout: northwind db for mysql
failed on: c
1. onnecting to database when used in another project, 
2. classes for employee had many problems and had to be wrote by hand
3. ignored the views
4. ignored the stored procedures

hi there,

seem to have a problem with connectiong to mysql,
i can use the studio fine, and i can follow this video tutorial :

http://www.codesmithtools.com/video/nhibernate.html

and everything builds fine, however once it comes to testing or adding into
a project and testing, nhibernate throws out exceptions with regards to
conneccting to DB:

here is the config
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
        <session-factory>
                <property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</prope
rty>
                <property
name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
                <property
name="connection.connection_string">Server=localhost;Database=northwind;User 
ID=root;Password=*******;</property>
                <property
name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
                <mapping assembly="codesmith_northwind" />
        </session-factory>
</hibernate-configuration>

and here is the error:

codesmith_northwind.UnitTests.CategoryTests (TestFixtureSetUp):
System.TypeInitializationException : The type initializer for
'NHibernate.Cfg.Environment' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an
instance of an object.codesmith_northwind.UnitTests.CategoryTests
(TestFixtureSetUp):
System.TypeInitializationException : The type initializer for
'NHibernate.Cfg.Environment' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an
instance of an object.

info on error:

at NHibernate.Cfg.Environment.get_Properties()
at NHibernate.Cfg.Configuration.Reset()
at NHibernate.Cfg.Configuration..ctor(SettingsFactory settingsFactory)
at NHibernate.Cfg.Configuration..ctor()
at codesmith_northwind.Base.NHibernateSessionManager..ctor() in
C:\codesmith_northwind\codesmith_northwind\codesmith_northwind\Base\NHibernateSe
ssionManager.cs:line
59
at codesmith_northwind.Base.NHibernateSessionManager.get_Instance() in
C:\codesmith_northwind\codesmith_northwind\codesmith_northwind\Base\NHibernateSe
ssionManager.cs:line
35
at codesmith_northwind.Base.ManagerBase`2..ctor() in
C:\codesmith_northwind\codesmith_northwind\codesmith_northwind\Base\ManagerBase.
cs:line
44
at codesmith_northwind.ManagerObjects.CategoryManager..ctor() in
C:\codesmith_northwind\codesmith_northwind\codesmith_northwind\ManagerObjects\Ca
tegoryManager.Generated.cs:line
21
at codesmith_northwind.ManagerObjects.ManagerFactory.GetCategoryManager()
in
C:\codesmith_northwind\codesmith_northwind\codesmith_northwind\ManagerObjects\Ma
nagerFactory.cs:line
50
at codesmith_northwind.UnitTests.CategoryTests..ctor() in
C:\codesmith_northwind\codesmith_northwind\codesmith_northwind\UnitTests\Categor
yTests.generated.cs:line
18
--NullReferenceException
at NHibernate.Cfg.Environment.LoadGlobalPropertiesFromAppConfig()
at NHibernate.Cfg.Environment..cctor()

you apparently do support mysql, and nhibernate defo supports mysql so can
you help out here, am trying to get into MVC etc.

thanks

dave

p.s please note correction has to be made manually to the stored procedure 
for the database script.

i have included a report from nunit 2.5

Original issue reported on code.google.com by helenros...@googlemail.com on 28 Jan 2009 at 5:55

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 28 Jan 2009 at 10:15

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 2 Feb 2009 at 1:50

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 2 Feb 2009 at 1:50

GoogleCodeExporter commented 9 years ago
I couldn't execute your schema script. Could you please double check it..

   W (1): You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ''Categories' (
  'CategoryID' int(10) NOT NULL auto_increment,
  'CategoryName' ' at line 1

Original comment by bniemyjski on 2 Feb 2009 at 2:04

GoogleCodeExporter commented 9 years ago
well i would just delete categories table, i have now gone with subsonic, as 
subsonic
works with mysql

as for the script:

CREATE TABLE `Categories` (
  `CategoryID` int(10) NOT NULL auto_increment,
  `CategoryName` varchar(15) NOT NULL,
  `Description` longtext,
  `Picture` longblob,
  PRIMARY KEY  (`CategoryID`),
  KEY `CategoryName` (`CategoryName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

there is nohing i can see wrong with that, i ran this in phpmyadmin and on 
navicat
and no issues! you do know this is for MySQL database and not mssql

thanks

p.s the database is not an issue as such, the issue is that codesmith removes 
the
support for mysql that nhibernate originally has.

Original comment by helenros...@googlemail.com on 4 Feb 2009 at 9:17

GoogleCodeExporter commented 9 years ago
Hello,

I'll try running this with another tool. I was using Aqua Data Studio to run 
this
query against MySQL.

I'll update this issue when it is resolved.

"the database is not an issue as such, the issue is that codesmith removes the
support for mysql that nhibernate originally has."

I have logged this as a separate ticket.

Original comment by bniemyjski on 4 Feb 2009 at 3:17

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 21 Apr 2009 at 3:58

GoogleCodeExporter commented 9 years ago
Has there been any progress on this. I have been looking at codesmith + 
Nhibernate + 
mysql too but not having views for MySql is a big showstopper since it renders 
the 
templates useless:s

Original comment by mvh...@gmail.com on 12 May 2009 at 3:49

GoogleCodeExporter commented 9 years ago
Issue 71 has been merged into this issue.

Original comment by bniemyjski on 2 Jul 2009 at 11:31

GoogleCodeExporter commented 9 years ago
Hello,

I was unable to reproduce this issue, please make sure your app.config looks
something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</prope
rty>
      <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
      <property
name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
      <property
name="connection.connection_string">Server=localhost;Database=northwind;Uid=root
;Pwd=*****;</property>
      <mapping assembly="Northwind"/>
    </session-factory>
  </hibernate-configuration>

  <!--
  NHibernate.HibernateException:="" The IDbCommand and IDbConnection implementation
in the assembly MySql.Data could not be found.
  Ensure that the assembly MySql.Data is located in the application directory or in
the Global Assembly Cache.
  If the assembly is in the GAC, use <qualifyAssembly/> element in the application
configuration file to specify the full name of the assembly.
  -->
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <qualifyAssembly partialName="MySql.Data" fullName="MySql.Data,
Version=1.0.10.1, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </assemblyBinding>
  </runtime>
</configuration>

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 2 Jul 2009 at 2:32