I cannot really tell what the error is, but I am also a beginner and
also started with an existing Hibernate configuration the same way as
you did, so it will be only a small mistake.
One thing I think is important is that Tapestry Hibernate
automatically configures all @Entity classes in the "....entities"
package.
So I think you have to remove the "mapping" entry in the
hibernate-config. Either an entity is configured by hibernate config
or programatically (by tapestry in this case), but not both.
Marcus.
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>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]