-->
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.  [ 2 posts ] 
Author Message
 Post subject: Schemaupdate funktioniert nicht (hbm2ddl.auto=update)
PostPosted: Mon Nov 28, 2005 1:00 pm 
Newbie

Joined: Mon Nov 28, 2005 12:07 pm
Posts: 17
Hallo ihr Winterschläfer ;)
Mein Problem: Schemaupdate funktioniert nicht!
Hibernate version:
latest version 3.1 rc3, Nov 17, 2005
ausserdem:
JBoss AS 4.0.3SP1
JBoss JBPM 3.0.2
JDK 1.5.0_04
Name and version of the database you are using:
HSQL (Hypersonic)

Full stack trace of any exception that occurs:

    17:20:58,215 ERROR [JDBCExceptionReporter] Table not found in statement [insert into JBPM_ID_VERSION (VERSION_, CLASS_,
    ID_) values (?, 'U', null)]
    17:20:58,231 ERROR [[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception
    javax.management.RuntimeMBeanException
    at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:162)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:149)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
    at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:243)
    at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:208)
    at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:247)
    at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:85)
    at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: org.hibernate.exception.SQLGrammarException: could not insert: [org.jbpm.identity.Version]
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1985)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2404)
    at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEv
    entListener.java:186)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java
    :33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.j
    ava:175)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java
    :70)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:525)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:515)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:511)
    at org.jbpm.identity.hibernate.IdentitySession.saveVersion(IdentitySession.java:134)
    at org.jbpm.identity.mbean.IdentitiesService.addVersion(IdentitiesService.java:194)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
    ... 33 more
    Caused by: java.sql.SQLException: Table not found in statement [insert into JBPM_ID_VERSION (VERSION_, CLASS_, ID_) valu
    es (?, 'U', null)]
    at org.hsqldb.jdbc.Util.throwError(Unknown Source)
    at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
    at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
    at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.ja
    va:312)
    at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:172)
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:442)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1947)
    ... 54 more


Habe zu einem bestehendem Datenmodell (identities von JBPM) eine neue Klasse hinzugefuegt:
Code:
package org.jbpm.identity;

import java.io.Serializable;

public class Version  implements Serializable {

   private static final long serialVersionUID = 1L;
   
   long id = 0;
   
   private double version = 0.0;
   
   public Version() {   
   }
   
   public Version(double version) {
      this.version = version;
   }
   
   public void setId(long id) {
      this.id = id;
   }

   public long getId() {
      return id;
   }
   
   public double getVersion() {
      return version;
   }   

   public void setVersion(double version) {
      this.version = version;
   }
}

das mapping file: version.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

  <class name="org.jbpm.identity.Version"
         table="JBPM_ID_VERSION"
         discriminator-value="U">
    <id name="id" column="ID_"><generator class="native" /></id>
    <discriminator type="char" column="CLASS_"/>
    <property name="version" column="VERSION_" type="java.lang.Double"/>
  </class>

</hibernate-mapping>

hibernate.cfg.xml
Code:
<?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>

    <!-- jdbc connection properties -->
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:.;sql.enforce_strict_size=true</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password"></property>
       
    <!-- c3p0 connection pooling properties
    <property name="hibernate.c3p0.min_size">1</property>
    <property name="hibernate.c3p0.max_size">3</property>
    -->

    <!-- other hibernate properties -->
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.hbm2ddl.auto">update</property>

    <!--identity mapping files -->
    <!-- uncomment if you don't want to use the default jBPM identity mgmgt component -->
    <mapping resource="org/jbpm/identity/User.hbm.xml"/>
    <mapping resource="org/jbpm/identity/Group.hbm.xml"/>
    <mapping resource="org/jbpm/identity/Membership.hbm.xml"/>
    <mapping resource="org/jbpm/identity/Version.hbm.xml"/>

    <!-- graph.def mapping files -->
    <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>
...

Das Config-File hab ich wie folgt verändert:
1. Property hibernate.hbm2ddl.auto=update hinzugefügt
2. Mapping 'Version.hbm.xml' hinzugefügt

Was ich bisher probiert habe:
<hibernate-mapping default-access="field">
und Property ohne type: <property name="version" column="VERSION_">

Meine Fragen:
1. wie krieg ich es gebacken dass die Schema zur Laufzeit angepasst wird und die fehlenden Datensätze erzeugt werden?
2. dachte, allein ein session.save(object) reicht für die Schemageschichte - falsch?
3. wie kann ich _ohne_ ein Objekt zu speichern die Tabelle leer anlegen lassen?
4. was bedeutet dieses 'default-access' genau?
http://www.hibernate.org/hib_docs/v3/re ... on-mapping ist da nicht sehr auskunftfreudig
5. was bringt es mir keinen type im mapping-hbm file anzugeben?

Anbei noch ein bestehendes hbm-file aus dem jbpm-Projekt (nach der Arti ich 'version' auch bastelt wollte:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field">

  <class name="org.jbpm.identity.User"
         table="JBPM_ID_USER"
         discriminator-value="U">
    <id name="id" column="ID_"><generator class="native" /></id>
    <discriminator type="char" column="CLASS_"/>
    <property name="name" column="NAME_"/>
    <property name="email" column="EMAIL_"/>
    <property name="password" column="PASSWORD_"/>
    <set name="memberships" cascade="all">
      <key column="USER_" />
      <one-to-many class="org.jbpm.identity.Membership" />
    </set>
    <set name="permissions" cascade="all" table="JBPM_ID_PERMISSIONS">
      <key column="ENTITY_" foreign-key="none" />
      <element type="org.jbpm.identity.hibernate.PermissionUserType">
        <column name="CLASS_"/>
        <column name="NAME_"/>
        <column name="ACTION_"/>
      </element>
    </set>
  </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 1:15 pm 
Newbie

Joined: Mon Nov 28, 2005 12:07 pm
Posts: 17
hm, editieren geht gar nicht? *seltsam*

wollte noch hinzufuegen dass ich z.B. ein addVersion() in einem MBean ausfuehre (per jmx-console). Der Code ist wie folgt:
Code:
   public void addVersion(Double version) {
      Version v = new Version(version.doubleValue());
      JbpmSession jbpmSession = JbpmSessionFactory.getInstance()
            .openJbpmSession();
      session = new IdentitySession(jbpmSession.getSession());
      session.beginTransaction();
      session.saveVersion(v);
      session.commitTransactionAndClose();
      jbpmSession.close();
   }

Wobei das JbpmSession ein Hibernate-Session Objekt wrapped. In dem konkreten Fall wird das save nur durchgeleitet:
Code:
public void saveVersion(Version version) {
      session.save(version);
   }


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