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.  [ 5 posts ] 
Author Message
 Post subject: hello, i need help with the configuration
PostPosted: Wed Jun 04, 2008 5:55 am 
Newbie

Joined: Wed Jun 04, 2008 4:24 am
Posts: 4
I cant really find the problem i am having here, i dont understand why it says the mapping is going wrong, if anyone could help me i would much apriciate it.

Hibernate version:
Nhibernate 2.0.0.ALPHA1
Mapping documents:

this is my mapping document for the table Persona.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="QuickStart" assembly="QuickStart">
<class name="Persona" table="Persona">
<!-- A 32 hex character is our surrogate key. It's automatically
generated by NHibernate with the UUID pattern. -->
<id name="cedula">
<column name="cedula" sql-type="varchar2(16)" not-null="true"/>
<generator class="uuid.hex" />
</id>
<property name="nombre">
<column name="nombre" lenght="20" not-null="true" />
</property>
<property name="apellido" >
<column name="apellido" lenght="20" not-null="true" />
</property>
</class>
</hibernate-mapping>

this is my configuration file

<?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="dialect">NHibernate.Dialect.Oracle9Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="connection.connection_string">Data Source=localhost;Persist Security Info=True;User ID=XXXPassword=XXX;</property>
<property name="show_sql">true</property>
<mapping assembly="QuickStart"/>
</session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():
try
{
Configuration cfg = new Configuration();
cfg.Configure("hibernate.cfg.xml");

ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();

Persona lol = new Persona();
lol.Id = "17385976";
lol.Nombre = "Tomas";
lol.Apellido = "Henriquez";
session.Save(lol);
transaction.Commit();
session.Flush();
session.Close();
}
catch (Exception e) { MessageBox.Show("Error: " + e); }

}
Full stack trace of any exception that occurs:
NHibernate.MappingException: Unknown entity class: QuickStart.Persona
at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(Type theClass) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:line 781
at NHibernate.Impl.SessionImpl.GetClassPersister(Type theClass) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 1230
at NHibernate.Impl.SessionImpl.GetEntityPersister(Object obj) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 1238
at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Event\Default\AbstractSaveEventListener.cs:line 106
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs:line 162
at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Event\Default\DefaultSaveEventListener.cs:line 29
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs:line 148
at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Event\Default\DefaultSaveEventListener.cs:line 21
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Event\Default\DefaultSaveOrUpdateEventListener.cs:line 53
at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 2165
at NHibernate.Impl.SessionImpl.Save(Object obj) in c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 407
at QuickStart.NH.Main(String[] args) in C:\Documents and Settings\Tommy\Mis documentos\Visual Studio 2005\Projects\Prueba\Prueba\NH.cs:line 35

Name and version of the database you are using:
Oracle XE


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 04, 2008 6:56 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I don't think, you can specifiy a complete assembly with

<mapping assembly="QuickStart"/>

You have to specifiy each mapping file

<mapping ressource="QuickStart.Persona.hbm.xml" assembly="QuickStart"/>

Alternativly, you can add a complete assembly with

cfg.AddAssembly("QuickStart");

But then make sure, you've marked your mapping files as "Embedded Ressource".

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 04, 2008 7:48 am 
Newbie

Joined: Wed Jun 04, 2008 4:24 am
Posts: 4
hahaha i got the solution, well i havent sleeped in a long time but here it is, a little dumb i am answering myself but maybe someone could use it.

first i made the persona.hbm.xml a embeded resource, after that i added this to the hibernate-mapping tag (what appears resalted below). then i told me about the lazy thingy, i put it off cause i just use 1 table, but check this out if you want to understand it better. http://blogs.chayachronicles.com/sonofn ... 0/230.aspx

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="QuickStart" namespace="QuickStart">
<class name="Persona" table="persona" lazy="false">
<id name="Id">
<column name="cedula" sql-type="varchar2(16)" not-null="true"/>
<generator class="assigned" />
</id>
<property name="Nombre">
<column name="nombre" sql-type="varchar2(20)" length="20" not-null="true" />
</property>
<property name="Apellido" >
<column name="apellido" sql-type="varchar2(20)" length="20" not-null="true" />
</property>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 04, 2008 7:49 am 
Newbie

Joined: Wed Jun 04, 2008 4:24 am
Posts: 4
ok thx :)


Last edited by Tomas on Wed Jun 04, 2008 7:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 04, 2008 7:50 am 
Newbie

Joined: Wed Jun 04, 2008 4:24 am
Posts: 4
ok thx :)


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