see your hibernate.cfg.xml file. Jun Tsai
2007/9/10, Angelo Chen <[EMAIL PROTECTED]>: > > > Hi Davor, > > I read the doc and do the following: > > 1. put Fruit.java under entities package > 2. put hibernate.cfg.xml under resources > 3. in the Start.java, I add: > @Inject private Session _session; > > String onAction() { > Fruit f = new Fruit(); > f.setName("Orange"); > f.setPrice(10); > _session.save(f); > _session.close(); > return null; } > > I got following error: > > The content of element type "session-factory" must match > "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)". > > here are the related files: > > Fruit.java > package org.bfe.hbm.entities; > import javax.persistence.*; > @Entity > @Table(name="Fruit") > public class Fruit { > @Id @GeneratedValue > private long id; > private String name; > private int price; > public long getId() { > return id; } > public void setId(long id) { > this.id = id; } > public String getName() { > return name; > } > public void setName(String name) { > this.name = name; } > public int getPrice() { > return price; } > public void setPrice(int price) { > this.price = price; } > } > > hibernate.cfg.xml:(note: this is taken from a working app, except changed > mapping class from xml to anotated) > > <?xml version='1.0' encoding='utf-8'?> > <!DOCTYPE hibernate-configuration PUBLIC > "-//Hibernate/Hibernate Configuration DTD 3.0//EN" > "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd > "> > > <hibernate-configuration> > > <session-factory> > > <!-- Database connection settings --> > <!-- <property > name="connection.driver_class">org.hsqldb.jdbcDriver</property> > <property > name="connection.url">jdbc:hsqldb:hsql://localhost</property> > <property name="connection.username">sa</property> > <property name="connection.password"></property> > --> > > <!-- Database connection settings --> > <property > name="connection.driver_class">com.mysql.jdbc.Driver</property> > <property > name="connection.url">jdbc:mysql://localhost/animal</property> > <property name="connection.username">root</property> > <property name="connection.password"></property> > > <!-- JDBC connection pool (use the built-in) --> > <property name="connection.pool_size">1</property> > > <!-- SQL dialect --> > <property > name="dialect">org.hibernate.dialect.MySQLDialect</property> > > <!-- Enable Hibernate's automatic session context management --> > <property name="current_session_context_class">thread</property> > > <!-- Disable the second-level cache --> > <property > name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> > > <!-- Echo all executed SQL to stdout --> > <property name="show_sql">true</property> > > <!-- Drop and re-create the database schema on startup --> > <property name="hbm2ddl.auto">create</property> - > > <mapping class="org.bfe.hbm.entities.Fruit" /> > > > > </session-factory> > > </hibernate-configuration> > > > Davor Hrg wrote: > > > > not much at the moment, > > but it's simple to use, > > factories are created > > http://tapestry.apache.org/tapestry5/tapestry-hibernate/conf.html > > > > you just call > > @Inject private Session _session; > > > > > > -- > View this message in context: > http://www.nabble.com/T5%3A-Hibernate-tf4409684.html#a12586367 > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- regards, Jun Tsai