hibernate - Attribute "name" must be declared for element type "mapping" -


i'm getting error: caused by: org.xml.sax.saxparseexception; linenumber: 35; columnnumber: 44; attribute "name" must declared element type "mapping". problem line <mapping name="org.one.dto.userdetails" /> why doesn't find name attribute

below hibernate.cfg.xml file content:

<?xml version='1.0' encoding='utf-8'?> <!doctype hibernate-configuration public         "-//hibernate/hibernate configuration dtd 3.0//en"         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">  <hibernate-configuration>     <session-factory>         <!-- database connection settings -->         <property name="connection.driver_class">org.postgresql.driver</property>         <property name="connection.url">jdbc:postgresql://localhost:5433/hibernatedb         </property>         <property name="connection.username"></property>         <property name="connection.password">tere123</property>          <!-- jdbc connection pool (use built-in) -->         <property name="connection.pool_size">1</property>          <!-- sql dialect -->         <property name="dialect">org.hibernate.dialect.postgresqldialect         </property>          <!-- enable hibernate's automatic session context management -->         <property name="current_session_context_class">thread</property>          <!-- disable second-level cache -->         <property name="cache.provider_class">org.hibernate.cache.internal.nocacheprovider         </property>          <!-- echo executed sql stdout -->         <property name="show_sql">true</property>          <!-- drop , re-create database schema on startup -->         <property name="hbm2ddl.auto">create</property>          <mapping name="org.one.dto.userdetails" />          </session-factory> </hibernate-configuration> 

here's main class:

package org.one;  import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.cfg.configuration; import org.hibernate.service.serviceregistry; import org.hibernate.service.serviceregistrybuilder; import org.one.dto.userdetails;  public class hibernatetest {     private static serviceregistry serviceregistry;      public static void main(string[] args){          userdetails user = new userdetails();         user.setid(1);         user.setusername("laura");         configuration configuration = new configuration();         configuration.configure();         serviceregistry = new serviceregistrybuilder().applysettings(configuration.getproperties()).buildserviceregistry();          sessionfactory sessionfactory = configuration.buildsessionfactory(serviceregistry);         session session = sessionfactory.opensession();         session.begintransaction();         session.save(user);         session.gettransaction().commit();      } } 

can tell wrong?

mapping tag takes these attributes

<!element mapping empty> <!-- reference mapping file --> <!attlist mapping resource cdata #implied> <!attlist mapping file cdata #implied> <!attlist mapping jar cdata #implied> <!attlist mapping package cdata #implied> <!attlist mapping class cdata #implied> 

it not have name attribute listed.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -