-->
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.  [ 6 posts ] 
Author Message
 Post subject: NHibernate a PostGreSQL
PostPosted: Wed Dec 28, 2005 5:00 pm 
Newbie

Joined: Wed Dec 28, 2005 4:54 pm
Posts: 10
Hi everybody:

I'm trying to make an example of the use of NHibernate with POstGreSQL.

I already have the mapping file:

<?xml version="1.0" encoding="utf-8" ?>
- <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="Prision" assembly="Prision">
- <class name="Imagenes" table="Imagenes" schema="public">
- <id name="key" column="id" type="String">
<generator class="assigned" />
</id>
<property name="name" type="String" column="name" />
</class>
</hibernate-mapping>

and the mapped class:

public class Imagenes
{

private string _key;
private string _name;

public Imagenes()
{
}

protected string key {
get{return this._key ; }
set{this._key = value ; }
}

protected string name
{
get{return this._name ; }
set{this._name = value ; }
}

// public
public string Key
{
get{return this._key ; }
set{this._key = value ; }
}

public string Name
{
get{return this._name ; }
set{this._name = value ; }
}

}
}


The problem comes when I try to make an insertion or load from the table. I'm using the following code and when I call the Save o Load Method I receive an Exception: could not insert/load Prisiones.Imagenes#1
The code is:
Configuration config = new Configuration();
IDictionary props = new Hashtable();

props["hibernate.connection.provider"] =
"NHibernate.Connection.DriverConnectionProvider";
props["hibernate.dialect" ] = "NHibernate.Dialect.PostgreSQLDialect";
props["hibernate.connection.driver_class"] =
"NHibernate.Driver.NpgsqlDriver" ;
props["hibernate.connection.connection_string"] =
"Server=10.128.23.155;Port=5432;User Id=alejandro;Password=alejandro;Database=NTest;" ;
props["hibernate.cache.provider_class"]="NHibernate.Cache.HashtableCacheProvider, NHibernate" ;

props["hibernate.cache.use_query_cache"]= "true" ;
props["hibernate.use_reflection_optimizer"] = "false" ;
props["show_sql"] = "false" ;


foreach( DictionaryEntry de in props )
{
config.SetProperty( de.Key.ToString(), de.Value.ToString() );
}

config.AddAssembly("Prision");

ISessionFactory fact = config.BuildSessionFactory() ;
ISession sesion = fact.OpenSession();
ITransaction st = sesion.BeginTransaction() ;
Imagenes nueva = (Imagenes)sesion.Load(typeof(Imagenes),"1") ;
st.Commit();
sesion.Close() ;

Any help???
Please!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:23 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Do you want to "load" an instance of an object from the data in the database, or are you trying to "save" an object to the database? This error message just means "record not found". Is there a different error when saving?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:27 pm 
Newbie

Joined: Wed Dec 28, 2005 4:54 pm
Posts: 10
Nope when I try to save I receive a similar Exception:
could not save Prision.Imagenes#1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:30 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Please post the stack trace, because the root cause is usually a few levels deep. Enabling the log4net logging and posting the related log sections would be even better. http://wiki.nhibernate.org/display/NH/Configuring+log4net+Logging


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:41 pm 
Newbie

Joined: Wed Dec 28, 2005 4:54 pm
Posts: 10
I don't now if this what you want:

'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.

'Prision': Loaded 'D:\WorkSpace\Prision\Prision.exe', Symbols loaded.

'Prision.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.

'Prision.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.

'Prision.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.

'Prision.exe': Loaded 'd:\workspace\prision\nhibernate.dll', No symbols loaded.

'Prision.exe': Loaded 'c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll', No symbols loaded.

'Prision.exe': Loaded 'd:\workspace\prision\log4net.dll', No symbols loaded.

'Prision.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded.

'Prision.exe': Loaded 'd:\workspace\prision\iesi.collections.dll', No symbols loaded.

'Prision.exe': Loaded 'd:\workspace\prision\npgsql.dll', No symbols loaded.

'Prision.exe': Loaded 'oh-9tkbl', No symbols loaded.

'Prision.exe': Loaded 'd:\workspace\prision\mono.security.dll', No symbols loaded.

NHibernate :SELECT imagenes0_.id as id0_, imagenes0_.name as name0_ FROM public.Imagenes imagenes0_ WHERE imagenes0_.id=:p0

An unhandled exception of type 'NHibernate.ADOException' occurred in nhibernate.dll



Additional information: could not load: [Prision.Imag


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:44 pm 
Newbie

Joined: Wed Dec 28, 2005 4:54 pm
Posts: 10
Last line was incomplete sorry

Additional information: could not load: [Prision.Imagenes#1]


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