Re: rendering a page for an email: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-09-07 Thread Jeremy Thomerson
On Fri, Sep 3, 2010 at 12:10 PM, Fernando Wermus
fernando.wer...@gmail.comwrote:

 Hi all,
 I have coded the following to render a mail,


 Application app;
 try{
 app=MyApplication.get();
 }catch(Exception e){
 app=new WicketTester().getApplication();
 }
 final Application app2=app;
 final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
 @Override
 protected void beforeExecute(final Thread t, final Runnable r) {
 Application.set(app2);
 };
 @Override
 protected void afterExecute(final Runnable r, final Throwable t) {
 Application.unset();
 }
 };
 service.submit(new ThreadMail(destinatarios, clazz, p));

 But, I got a org.hibernate.HibernateException: createCriteria is not valid
 without active transaction
 when I tried to load an entity in a model to be used in the PageMail.

 How can I attach the Transaction to the thread to get this working?

 thanks in advance

 --
 Fernando Wermus.

 www.linkedin.com/in/fernandowermus



This has nothing in particular to do with Wicket, and would be hard to
answer without knowing the details of what you are doing for transaction
management.

-- 
Jeremy Thomerson
http://www.wickettraining.com


rendering a page for an email: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-09-03 Thread Fernando Wermus
Hi all,
 I have coded the following to render a mail,


Application app;
try{
app=MyApplication.get();
}catch(Exception e){
app=new WicketTester().getApplication();
}
final Application app2=app;
final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
@Override
protected void beforeExecute(final Thread t, final Runnable r) {
Application.set(app2);
};
@Override
protected void afterExecute(final Runnable r, final Throwable t) {
Application.unset();
}
};
service.submit(new ThreadMail(destinatarios, clazz, p));

But, I got a org.hibernate.HibernateException: createCriteria is not valid
without active transaction
when I tried to load an entity in a model to be used in the PageMail.

How can I attach the Transaction to the thread to get this working?

thanks in advance

-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus


org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-05-08 Thread Richard Slide
Hello all,
i try to do a simple web application with the classic layout
Wicket-Spring-Hibernate

When i try to make a simple request i receive the following error.

WicketMessage: Error attaching this container for rendering: [Page class =
ch.myexample.ListContacts, id = 0, version = 0]
Root cause:
org.hibernate.HibernateException: createCriteria is not valid without active
transaction

In IMHO all file conf seams to be correct correct... bat i don't undestand
hibenate dosen't find the correct session.

At UI level i load the data with LoadableDetachableModel

IModel contactsModel = new LoadableDetachableModel() {
protected Object load() {
return
WicketApplication.get().getContactService().findAllContacts();
}
};

--applicationContext from here --

bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource
property name=driverClassName
value${jdbc.driver}/value
/property
property name=url
value${jdbc.url}/value
/property
property name=username
value${jdbc.username}/value
/property
property name=password
value${jdbc.password}/value
/property
/bean

 !-- hibernate session factory --
bean id=sessionFactory

class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
property name=dataSource ref=dataSource /
property name=hibernateProperties
props
prop key=hibernate.dialect${hibernate.dialect}/prop
prop key=hibernate.connection.pool_size5/prop
prop
key=hibernate.current_session_context_classthread/prop
prop key=hibernate.show_sqltrue/prop
prop
key=hibernate.cglib.use_reflection_optimizertrue/prop
prop
key=hibernate.cache.provider_classorg.hibernate.cache.EhCacheProvider/prop
prop
key=hibernate.hibernate.cache.use_query_cachetrue/prop
/props
/property
property name=annotatedClasses
list
value
ch.myexample.domain.Contact
/value
/list
/property
/bean

!-- setup transaction manager--
bean id=transactionManager

class=org.springframework.orm.hibernate3.HibernateTransactionManager
property name=sessionFactory
ref bean=sessionFactory /
/property
/bean
tx:annotation-driven /
bean id=ContactDao class=ch.myexample.dao.impl.ContactDaoImpl
property name=sessionFactory ref=sessionFactory /
/bean
bean id=LocalServiceService
class=ch.myexample.services.LocalServiceImpl
property name=contactDao ref=ContactDao /
/bean
bean id=wicketApplication class=ch.myexample.WicketApplication
/bean
/beans


--
--applicationContext to here --

and web.xml

context-param
param-namecontextConfigLocation/param-name
param-value classpath:applicationContext.xml/param-value
/context-param
filter
filter-namewicket.WebProject/filter-name
filter-classorg.apache.wicket.protocol.http.WicketFilter
/filter-class
init-param
param-nameapplicationFactoryClassName
/param-name
param-value
org.apache.wicket.spring.SpringWebApplicationFactory
/param-value
/init-param
init-param
param-nameapplicationBean/param-name
param-value wicketApplication/param-value
/init-param
/filter
filter
filter-nameopensessioninview/filter-name
filter-class

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
/filter-class
/filter
filter-mapping
filter-nameopensessioninview/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-namewicket.WebProject/filter-name
url-pattern/*/url-pattern
/filter-mapping
listener

listener-classorg.springframework.web.context.ContextLoaderListener
/listener-class
/listener
/web-app


Could you tell me where is my mistake please

Cheers

--Richard


Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-05-08 Thread Karolina Rusin
Hello Richard,

Maybe you need to use @Transactional above your dao method?
Hope this helps.

Best regards,
Karolina Rusin


2010/5/8 Richard Slide richard.sl...@gmail.com

 Hello all,
 i try to do a simple web application with the classic layout
 Wicket-Spring-Hibernate

 When i try to make a simple request i receive the following error.

 WicketMessage: Error attaching this container for rendering: [Page class =
 ch.myexample.ListContacts, id = 0, version = 0]
 Root cause:
 org.hibernate.HibernateException: createCriteria is not valid without
 active
 transaction

 In IMHO all file conf seams to be correct correct... bat i don't undestand
 hibenate dosen't find the correct session.

 At UI level i load the data with LoadableDetachableModel

 IModel contactsModel = new LoadableDetachableModel() {
protected Object load() {
return
 WicketApplication.get().getContactService().findAllContacts();
}
};

 --applicationContext from here --

 bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource
property name=driverClassName
value${jdbc.driver}/value
/property
property name=url
value${jdbc.url}/value
/property
property name=username
value${jdbc.username}/value
/property
property name=password
value${jdbc.password}/value
/property
/bean

 !-- hibernate session factory --
bean id=sessionFactory


 class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
property name=dataSource ref=dataSource /
property name=hibernateProperties
props
prop key=hibernate.dialect${hibernate.dialect}/prop
prop key=hibernate.connection.pool_size5/prop
prop
 key=hibernate.current_session_context_classthread/prop
prop key=hibernate.show_sqltrue/prop
prop
 key=hibernate.cglib.use_reflection_optimizertrue/prop
prop

 key=hibernate.cache.provider_classorg.hibernate.cache.EhCacheProvider/prop
prop
 key=hibernate.hibernate.cache.use_query_cachetrue/prop
/props
/property
property name=annotatedClasses
list
value
ch.myexample.domain.Contact
/value
/list
/property
/bean

!-- setup transaction manager--
bean id=transactionManager

 class=org.springframework.orm.hibernate3.HibernateTransactionManager
property name=sessionFactory
ref bean=sessionFactory /
/property
/bean
tx:annotation-driven /
bean id=ContactDao class=ch.myexample.dao.impl.ContactDaoImpl
property name=sessionFactory ref=sessionFactory /
/bean
bean id=LocalServiceService
 class=ch.myexample.services.LocalServiceImpl
property name=contactDao ref=ContactDao /
/bean
bean id=wicketApplication class=ch.myexample.WicketApplication
/bean
 /beans


 --
 --applicationContext to here --

 and web.xml

 context-param
param-namecontextConfigLocation/param-name
param-value classpath:applicationContext.xml/param-value
/context-param
filter
filter-namewicket.WebProject/filter-name
filter-classorg.apache.wicket.protocol.http.WicketFilter
/filter-class
init-param
param-nameapplicationFactoryClassName
/param-name
param-value
 org.apache.wicket.spring.SpringWebApplicationFactory
/param-value
/init-param
init-param
param-nameapplicationBean/param-name
param-value wicketApplication/param-value
/init-param
/filter
filter
filter-nameopensessioninview/filter-name
filter-class

 org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
/filter-class
/filter
filter-mapping
filter-nameopensessioninview/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-namewicket.WebProject/filter-name
url-pattern/*/url-pattern
/filter-mapping
listener

 listener-classorg.springframework.web.context.ContextLoaderListener
/listener-class
/listener
 /web-app


 Could you tell me where is my mistake please

 Cheers

 --Richard



Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-05-08 Thread Richard Slide
Yes i did it...
this is DAO and impl




public interface DaoT extends DomainObject {

@Transactional
void delete(T o);

T load(long id);

@Transactional
void save(T o);

@Transactional
ListT findAll();

int countAll();
}

and the implemetation  is

public abstract class AbstractHibernateDaoImplT extends DomainObject
implements DaoT {

  private ClassT domainClass;

  private SessionFactory sf;

  public AbstractHibernateDaoImpl(ClassT domainClass) {
this.domainClass = domainClass;
  }

  public SessionFactory getSessionFactory() {
return sf;
  }

  public void setSessionFactory(SessionFactory sf) {
this.sf = sf;
  }

  public void delete(T object) {
getSession().delete(object);
  }

  @SuppressWarnings(unchecked)
  public T load(long id) {
return (T) getSession().get(domainClass, id);
  }

  public void save(T object) {
getSession().saveOrUpdate(object);
  }

  @SuppressWarnings(unchecked)
  public ListT findAll() {
Criteria criteria = getSession().createCriteria(domainClass);
return (ListT) criteria.list();
  }

  public int countAll() {
Criteria criteria = getSession().createCriteria(domainClass);
criteria.setProjection(Projections.rowCount());
return (Integer) criteria.uniqueResult();
  }

  public Session getSession() {
// presumes a current session, which we have through the
// OpenSessionInViewFilter; doesn't work without that
return sf.getCurrentSession();
  }
}




On Sat, May 8, 2010 at 12:05 PM, Karolina Rusin iluu.li...@gmail.comwrote:

 Hello Richard,

 Maybe you need to use @Transactional above your dao method?
 Hope this helps.

 Best regards,
 Karolina Rusin


 2010/5/8 Richard Slide richard.sl...@gmail.com

  Hello all,
  i try to do a simple web application with the classic layout
  Wicket-Spring-Hibernate
 
  When i try to make a simple request i receive the following error.
 
  WicketMessage: Error attaching this container for rendering: [Page class
 =
  ch.myexample.ListContacts, id = 0, version = 0]
  Root cause:
  org.hibernate.HibernateException: createCriteria is not valid without
  active
  transaction
 
  In IMHO all file conf seams to be correct correct... bat i don't
 undestand
  hibenate dosen't find the correct session.
 
  At UI level i load the data with LoadableDetachableModel
 
  IModel contactsModel = new LoadableDetachableModel() {
 protected Object load() {
 return
  WicketApplication.get().getContactService().findAllContacts();
 }
 };
 
  --applicationContext from here --
 
  bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource
 property name=driverClassName
 value${jdbc.driver}/value
 /property
 property name=url
 value${jdbc.url}/value
 /property
 property name=username
 value${jdbc.username}/value
 /property
 property name=password
 value${jdbc.password}/value
 /property
 /bean
 
  !-- hibernate session factory --
 bean id=sessionFactory
 
 
 
 class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
 property name=dataSource ref=dataSource /
 property name=hibernateProperties
 props
 prop key=hibernate.dialect${hibernate.dialect}/prop
 prop key=hibernate.connection.pool_size5/prop
 prop
  key=hibernate.current_session_context_classthread/prop
 prop key=hibernate.show_sqltrue/prop
 prop
  key=hibernate.cglib.use_reflection_optimizertrue/prop
 prop
 
 
 key=hibernate.cache.provider_classorg.hibernate.cache.EhCacheProvider/prop
 prop
  key=hibernate.hibernate.cache.use_query_cachetrue/prop
 /props
 /property
 property name=annotatedClasses
 list
 value
 ch.myexample.domain.Contact
 /value
 /list
 /property
 /bean
 
 !-- setup transaction manager--
 bean id=transactionManager
 
  class=org.springframework.orm.hibernate3.HibernateTransactionManager
 property name=sessionFactory
 ref bean=sessionFactory /
 /property
 /bean
 tx:annotation-driven /
 bean id=ContactDao class=ch.myexample.dao.impl.ContactDaoImpl
 property name=sessionFactory ref=sessionFactory /
 /bean
 bean id=LocalServiceService
  class=ch.myexample.services.LocalServiceImpl
 property name=contactDao ref=ContactDao /
 /bean
 bean id=wicketApplication class=ch.myexample.WicketApplication
 /bean
  /beans
 
 
  --
  --applicationContext to here --
 
  and web.xml
 
  context-param
 param-namecontextConfigLocation/param-name
 param-value classpath:applicationContext.xml/param-value
 /context-param
 filter
 filter-namewicket.WebProject/filter

Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-05-08 Thread James Carman
Put it on the impl class.

On Sat, May 8, 2010 at 7:43 AM, Richard Slide richard.sl...@gmail.com wrote:
 Yes i did it...
 this is DAO and impl




 public interface DaoT extends DomainObject {

   �...@transactional
    void delete(T o);

    T load(long id);

   �...@transactional
    void save(T o);

   �...@transactional
    ListT findAll();

    int countAll();
 }

 and the implemetation  is

 public abstract class AbstractHibernateDaoImplT extends DomainObject
    implements DaoT {

  private ClassT domainClass;

  private SessionFactory sf;

  public AbstractHibernateDaoImpl(ClassT domainClass) {
    this.domainClass = domainClass;
  }

  public SessionFactory getSessionFactory() {
    return sf;
  }

  public void setSessionFactory(SessionFactory sf) {
    this.sf = sf;
  }

  public void delete(T object) {
    getSession().delete(object);
  }

 �...@suppresswarnings(unchecked)
  public T load(long id) {
    return (T) getSession().get(domainClass, id);
  }

  public void save(T object) {
    getSession().saveOrUpdate(object);
  }

 �...@suppresswarnings(unchecked)
  public ListT findAll() {
    Criteria criteria = getSession().createCriteria(domainClass);
    return (ListT) criteria.list();
  }

  public int countAll() {
    Criteria criteria = getSession().createCriteria(domainClass);
    criteria.setProjection(Projections.rowCount());
    return (Integer) criteria.uniqueResult();
  }

  public Session getSession() {
    // presumes a current session, which we have through the
    // OpenSessionInViewFilter; doesn't work without that
    return sf.getCurrentSession();
  }
 }




 On Sat, May 8, 2010 at 12:05 PM, Karolina Rusin iluu.li...@gmail.comwrote:

 Hello Richard,

 Maybe you need to use @Transactional above your dao method?
 Hope this helps.

 Best regards,
 Karolina Rusin


 2010/5/8 Richard Slide richard.sl...@gmail.com

  Hello all,
  i try to do a simple web application with the classic layout
  Wicket-Spring-Hibernate
 
  When i try to make a simple request i receive the following error.
 
  WicketMessage: Error attaching this container for rendering: [Page class
 =
  ch.myexample.ListContacts, id = 0, version = 0]
  Root cause:
  org.hibernate.HibernateException: createCriteria is not valid without
  active
  transaction
 
  In IMHO all file conf seams to be correct correct... bat i don't
 undestand
  hibenate dosen't find the correct session.
 
  At UI level i load the data with LoadableDetachableModel
 
  IModel contactsModel = new LoadableDetachableModel() {
             protected Object load() {
                 return
  WicketApplication.get().getContactService().findAllContacts();
             }
         };
 
  --applicationContext from here --
 
  bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource
         property name=driverClassName
             value${jdbc.driver}/value
         /property
         property name=url
             value${jdbc.url}/value
         /property
         property name=username
             value${jdbc.username}/value
         /property
         property name=password
             value${jdbc.password}/value
         /property
     /bean
 
      !-- hibernate session factory --
     bean id=sessionFactory
 
 
 
 class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
         property name=dataSource ref=dataSource /
         property name=hibernateProperties
             props
                 prop key=hibernate.dialect${hibernate.dialect}/prop
                 prop key=hibernate.connection.pool_size5/prop
                 prop
  key=hibernate.current_session_context_classthread/prop
                 prop key=hibernate.show_sqltrue/prop
                 prop
  key=hibernate.cglib.use_reflection_optimizertrue/prop
                 prop
 
 
 key=hibernate.cache.provider_classorg.hibernate.cache.EhCacheProvider/prop
                 prop
  key=hibernate.hibernate.cache.use_query_cachetrue/prop
             /props
         /property
         property name=annotatedClasses
             list
                 value
                     ch.myexample.domain.Contact
                 /value
             /list
         /property
     /bean
 
     !-- setup transaction manager    --
     bean id=transactionManager
 
  class=org.springframework.orm.hibernate3.HibernateTransactionManager
         property name=sessionFactory
             ref bean=sessionFactory /
         /property
     /bean
     tx:annotation-driven /
     bean id=ContactDao class=ch.myexample.dao.impl.ContactDaoImpl
         property name=sessionFactory ref=sessionFactory /
     /bean
     bean id=LocalServiceService
  class=ch.myexample.services.LocalServiceImpl
         property name=contactDao ref=ContactDao /
     /bean
     bean id=wicketApplication class=ch.myexample.WicketApplication
     /bean
  /beans
 
 
  --
  --applicationContext to here --
 
  and web.xml
 
  context-param
         param-namecontextConfigLocation/param-name
         param

Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-05-08 Thread Richard Slide
I did it.

On Sat, May 8, 2010 at 2:00 PM, James Carman
jcar...@carmanconsulting.comwrote:

 Put it on the impl class.

 On Sat, May 8, 2010 at 7:43 AM, Richard Slide richard.sl...@gmail.com
 wrote:
  Yes i did it...
  this is DAO and impl
 
 
 
 
  public interface DaoT extends DomainObject {
 
 @Transactional
 void delete(T o);
 
 T load(long id);
 
 @Transactional
 void save(T o);
 
 @Transactional
 ListT findAll();
 
 int countAll();
  }
 
  and the implemetation  is
 
  public abstract class AbstractHibernateDaoImplT extends DomainObject
 implements DaoT {
 
   private ClassT domainClass;
 
   private SessionFactory sf;
 
   public AbstractHibernateDaoImpl(ClassT domainClass) {
 this.domainClass = domainClass;
   }
 
   public SessionFactory getSessionFactory() {
 return sf;
   }
 
   public void setSessionFactory(SessionFactory sf) {
 this.sf = sf;
   }
 
   public void delete(T object) {
 getSession().delete(object);
   }
 
   @SuppressWarnings(unchecked)
   public T load(long id) {
 return (T) getSession().get(domainClass, id);
   }
 
   public void save(T object) {
 getSession().saveOrUpdate(object);
   }
 
   @SuppressWarnings(unchecked)
   public ListT findAll() {
 Criteria criteria = getSession().createCriteria(domainClass);
 return (ListT) criteria.list();
   }
 
   public int countAll() {
 Criteria criteria = getSession().createCriteria(domainClass);
 criteria.setProjection(Projections.rowCount());
 return (Integer) criteria.uniqueResult();
   }
 
   public Session getSession() {
 // presumes a current session, which we have through the
 // OpenSessionInViewFilter; doesn't work without that
 return sf.getCurrentSession();
   }
  }
 
 
 
 
  On Sat, May 8, 2010 at 12:05 PM, Karolina Rusin iluu.li...@gmail.com
 wrote:
 
  Hello Richard,
 
  Maybe you need to use @Transactional above your dao method?
  Hope this helps.
 
  Best regards,
  Karolina Rusin
 
 
  2010/5/8 Richard Slide richard.sl...@gmail.com
 
   Hello all,
   i try to do a simple web application with the classic layout
   Wicket-Spring-Hibernate
  
   When i try to make a simple request i receive the following error.
  
   WicketMessage: Error attaching this container for rendering: [Page
 class
  =
   ch.myexample.ListContacts, id = 0, version = 0]
   Root cause:
   org.hibernate.HibernateException: createCriteria is not valid without
   active
   transaction
  
   In IMHO all file conf seams to be correct correct... bat i don't
  undestand
   hibenate dosen't find the correct session.
  
   At UI level i load the data with LoadableDetachableModel
  
   IModel contactsModel = new LoadableDetachableModel() {
  protected Object load() {
  return
   WicketApplication.get().getContactService().findAllContacts();
  }
  };
  
   --applicationContext from here --
  
   bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource
  property name=driverClassName
  value${jdbc.driver}/value
  /property
  property name=url
  value${jdbc.url}/value
  /property
  property name=username
  value${jdbc.username}/value
  /property
  property name=password
  value${jdbc.password}/value
  /property
  /bean
  
   !-- hibernate session factory --
  bean id=sessionFactory
  
  
  
 
 class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
  property name=dataSource ref=dataSource /
  property name=hibernateProperties
  props
  prop
 key=hibernate.dialect${hibernate.dialect}/prop
  prop key=hibernate.connection.pool_size5/prop
  prop
   key=hibernate.current_session_context_classthread/prop
  prop key=hibernate.show_sqltrue/prop
  prop
   key=hibernate.cglib.use_reflection_optimizertrue/prop
  prop
  
  
 
 key=hibernate.cache.provider_classorg.hibernate.cache.EhCacheProvider/prop
  prop
   key=hibernate.hibernate.cache.use_query_cachetrue/prop
  /props
  /property
  property name=annotatedClasses
  list
  value
  ch.myexample.domain.Contact
  /value
  /list
  /property
  /bean
  
  !-- setup transaction manager--
  bean id=transactionManager
  
  
 class=org.springframework.orm.hibernate3.HibernateTransactionManager
  property name=sessionFactory
  ref bean=sessionFactory /
  /property
  /bean
  tx:annotation-driven /
  bean id=ContactDao class=ch.myexample.dao.impl.ContactDaoImpl
  property name=sessionFactory ref=sessionFactory /
  /bean
  bean id=LocalServiceService
   class=ch.myexample.services.LocalServiceImpl
  property name

Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2010-05-08 Thread James Carman
By the way, you might want to check out domdrides.  It has all this
implemented and tested for you

On May 8, 2010 8:41 AM, Richard Slide richard.sl...@gmail.com wrote:

I did it.

On Sat, May 8, 2010 at 2:00 PM, James Carman
jcar...@carmanconsulting.comwrote:


 Put it on the impl class.

 On Sat, May 8, 2010 at 7:43 AM, Richard Slide richard.sl...@gmail
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




org.hibernate.HibernateException: createCriteria is not valid without active transaction

2009-10-06 Thread Peter Arnulf Lustig
 get this error always! I don't understand why.

this is my hibernate.cfg.xml


hibernate-configuration
  session-factory name=session1
property 
name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property
property 
name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
property 
name=hibernate.connection.urljdbc:mysql://localhost:3306/mydb/property
property name=hibernate.connection.usernameroot/property
property 
name=hibernate.current_session_context_classorg.hibernate.context.ThreadLocalSessionContext/property
 
mapping resource=org/omikron/test/data/Ticket.hbm.xml/
mapping resource=org/omikron/test/data/Testprocedure.hbm.xml/
mapping resource=org/omikron/test/data/Tag.hbm.xml/
mapping resource=org/omikron/test/data/Testentity.hbm.xml/
mapping resource=org/omikron/test/data/Questionset.hbm.xml/
mapping resource=org/omikron/test/data/Administrator.hbm.xml/
mapping resource=org/omikron/test/data/Systemsetting.hbm.xml/
mapping resource=org/omikron/test/data/Question.hbm.xml/
  /session-factory
/hibernate-configuration



Do you have an idea?




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2009-10-06 Thread Pieter Degraeuwe
You did not setup your transactions properly.
Or you start your transaction manually, or if you like spring, you can let
spring manage it. (just add your transction annotations to your services,
and, done !

On Tue, Oct 6, 2009 at 9:15 AM, Peter Arnulf Lustig u...@yahoo.dewrote:

  get this error always! I don't understand why.

 this is my hibernate.cfg.xml


 hibernate-configuration
  session-factory name=session1
property
 name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property
property
 name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
property
 name=hibernate.connection.urljdbc:mysql://localhost:3306/mydb/property
property name=hibernate.connection.usernameroot/property
property
 name=hibernate.current_session_context_classorg.hibernate.context.ThreadLocalSessionContext/property
mapping resource=org/omikron/test/data/Ticket.hbm.xml/
mapping resource=org/omikron/test/data/Testprocedure.hbm.xml/
mapping resource=org/omikron/test/data/Tag.hbm.xml/
mapping resource=org/omikron/test/data/Testentity.hbm.xml/
mapping resource=org/omikron/test/data/Questionset.hbm.xml/
mapping resource=org/omikron/test/data/Administrator.hbm.xml/
mapping resource=org/omikron/test/data/Systemsetting.hbm.xml/
mapping resource=org/omikron/test/data/Question.hbm.xml/
  /session-factory
 /hibernate-configuration



 Do you have an idea?




 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pieter Degraeuwe
Systemworks bvba
Belgiëlaan 61
9070 Destelbergen
GSM: +32 (0)485/68.60.85
Email: pieter.degrae...@systemworks.be
visit us at http://www.systemworks.be


AW: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2009-10-06 Thread Peter Arnulf Lustig
How can I do it manually?


For example: I have a DataProvider class with a method:

public static Administrator getAdministrator(Integer id) {
Administrator administrator= (Administrator) 
HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(Administrator.class).add(Property.forName(id).eq(id)).uniqueResult();
return administrator;

}


I get the error message. How shall I modify the code?
I tried it with Transaction tx = ... and then tx.begin() tx.commit()  -- but 
then suddenly hibernate tries permanently to update an object... wired !




- Ursprüngliche Mail 
Von: Pieter Degraeuwe pieter.degrae...@systemworks.be
An: users@wicket.apache.org
Gesendet: Dienstag, den 6. Oktober 2009, 09:29:58 Uhr
Betreff: Re: org.hibernate.HibernateException: createCriteria is not valid  
without active transaction

You did not setup your transactions properly.
Or you start your transaction manually, or if you like spring, you can let
spring manage it. (just add your transction annotations to your services,
and, done !

On Tue, Oct 6, 2009 at 9:15 AM, Peter Arnulf Lustig u...@yahoo.dewrote:

  get this error always! I don't understand why.

 this is my hibernate.cfg.xml


 hibernate-configuration
  session-factory name=session1
property
 name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property
property
 name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
property
 name=hibernate.connection.urljdbc:mysql://localhost:3306/mydb/property
property name=hibernate.connection.usernameroot/property
property
 name=hibernate.current_session_context_classorg.hibernate.context.ThreadLocalSessionContext/property
mapping resource=org/omikron/test/data/Ticket.hbm.xml/
mapping resource=org/omikron/test/data/Testprocedure.hbm.xml/
mapping resource=org/omikron/test/data/Tag.hbm.xml/
mapping resource=org/omikron/test/data/Testentity.hbm.xml/
mapping resource=org/omikron/test/data/Questionset.hbm.xml/
mapping resource=org/omikron/test/data/Administrator.hbm.xml/
mapping resource=org/omikron/test/data/Systemsetting.hbm.xml/
mapping resource=org/omikron/test/data/Question.hbm.xml/
  /session-factory
 /hibernate-configuration



 Do you have an idea?




 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pieter Degraeuwe
Systemworks bvba
Belgiëlaan 61
9070 Destelbergen
GSM: +32 (0)485/68.60.85
Email: pieter.degrae...@systemworks.be
visit us at http://www.systemworks.be





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2009-10-06 Thread Pieter Degraeuwe
Indeed, when you start a transaction and get an object from the database,
hibernate wil persist changes to that object when you transaction (and thus
sesseion) is still open.
This is normal behaviour.

Note that it is in most cases a bad habit to use manual transaction
management...

On Tue, Oct 6, 2009 at 9:44 AM, Peter Arnulf Lustig u...@yahoo.dewrote:

 How can I do it manually?


 For example: I have a DataProvider class with a method:

 public static Administrator getAdministrator(Integer id) {
Administrator administrator= (Administrator)
 HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(Administrator.class).add(Property.forName(id).eq(id)).uniqueResult();
return administrator;

}


 I get the error message. How shall I modify the code?
 I tried it with Transaction tx = ... and then tx.begin() tx.commit()  --
 but then suddenly hibernate tries permanently to update an object... wired !




 - Ursprüngliche Mail 
 Von: Pieter Degraeuwe pieter.degrae...@systemworks.be
 An: users@wicket.apache.org
 Gesendet: Dienstag, den 6. Oktober 2009, 09:29:58 Uhr
 Betreff: Re: org.hibernate.HibernateException: createCriteria is not valid
  without active transaction

 You did not setup your transactions properly.
 Or you start your transaction manually, or if you like spring, you can let
 spring manage it. (just add your transction annotations to your services,
 and, done !

 On Tue, Oct 6, 2009 at 9:15 AM, Peter Arnulf Lustig u...@yahoo.de
 wrote:

   get this error always! I don't understand why.
 
  this is my hibernate.cfg.xml
 
 
  hibernate-configuration
   session-factory name=session1
 property
  name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property
 property
  name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
 property
 
 name=hibernate.connection.urljdbc:mysql://localhost:3306/mydb/property
 property name=hibernate.connection.usernameroot/property
 property
 
 name=hibernate.current_session_context_classorg.hibernate.context.ThreadLocalSessionContext/property
 mapping resource=org/omikron/test/data/Ticket.hbm.xml/
 mapping resource=org/omikron/test/data/Testprocedure.hbm.xml/
 mapping resource=org/omikron/test/data/Tag.hbm.xml/
 mapping resource=org/omikron/test/data/Testentity.hbm.xml/
 mapping resource=org/omikron/test/data/Questionset.hbm.xml/
 mapping resource=org/omikron/test/data/Administrator.hbm.xml/
 mapping resource=org/omikron/test/data/Systemsetting.hbm.xml/
 mapping resource=org/omikron/test/data/Question.hbm.xml/
   /session-factory
  /hibernate-configuration
 
 
 
  Do you have an idea?
 
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 


 --
 Pieter Degraeuwe
 Systemworks bvba
 Belgiëlaan 61
 9070 Destelbergen
 GSM: +32 (0)485/68.60.85
 Email: pieter.degrae...@systemworks.be
 visit us at http://www.systemworks.be





 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pieter Degraeuwe
Systemworks bvba
Belgiëlaan 61
9070 Destelbergen
GSM: +32 (0)485/68.60.85
Email: pieter.degrae...@systemworks.be
visit us at http://www.systemworks.be


AW: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2009-10-06 Thread Peter Arnulf Lustig
ok!
So I need  a listener class  like HibernateListener and a Transactionfactory in 
the config xml ?






- Ursprüngliche Mail 
Von: Pieter Degraeuwe pieter.degrae...@systemworks.be
An: users@wicket.apache.org
Gesendet: Dienstag, den 6. Oktober 2009, 09:49:42 Uhr
Betreff: Re: org.hibernate.HibernateException: createCriteria is not valid  
without active transaction

Indeed, when you start a transaction and get an object from the database,
hibernate wil persist changes to that object when you transaction (and thus
sesseion) is still open.
This is normal behaviour.

Note that it is in most cases a bad habit to use manual transaction
management...

On Tue, Oct 6, 2009 at 9:44 AM, Peter Arnulf Lustig u...@yahoo.dewrote:

 How can I do it manually?


 For example: I have a DataProvider class with a method:

 public static Administrator getAdministrator(Integer id) {
Administrator administrator= (Administrator)
 HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(Administrator.class).add(Property.forName(id).eq(id)).uniqueResult();
return administrator;

}


 I get the error message. How shall I modify the code?
 I tried it with Transaction tx = ... and then tx.begin() tx.commit()  --
 but then suddenly hibernate tries permanently to update an object... wired !




 - Ursprüngliche Mail 
 Von: Pieter Degraeuwe pieter.degrae...@systemworks.be
 An: users@wicket.apache.org
 Gesendet: Dienstag, den 6. Oktober 2009, 09:29:58 Uhr
 Betreff: Re: org.hibernate.HibernateException: createCriteria is not valid
  without active transaction

 You did not setup your transactions properly.
 Or you start your transaction manually, or if you like spring, you can let
 spring manage it. (just add your transction annotations to your services,
 and, done !

 On Tue, Oct 6, 2009 at 9:15 AM, Peter Arnulf Lustig u...@yahoo.de
 wrote:

   get this error always! I don't understand why.
 
  this is my hibernate.cfg.xml
 
 
  hibernate-configuration
   session-factory name=session1
 property
  name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property
 property
  name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
 property
 
 name=hibernate.connection.urljdbc:mysql://localhost:3306/mydb/property
 property name=hibernate.connection.usernameroot/property
 property
 
 name=hibernate.current_session_context_classorg.hibernate.context.ThreadLocalSessionContext/property
 mapping resource=org/omikron/test/data/Ticket.hbm.xml/
 mapping resource=org/omikron/test/data/Testprocedure.hbm.xml/
 mapping resource=org/omikron/test/data/Tag.hbm.xml/
 mapping resource=org/omikron/test/data/Testentity.hbm.xml/
 mapping resource=org/omikron/test/data/Questionset.hbm.xml/
 mapping resource=org/omikron/test/data/Administrator.hbm.xml/
 mapping resource=org/omikron/test/data/Systemsetting.hbm.xml/
 mapping resource=org/omikron/test/data/Question.hbm.xml/
   /session-factory
  /hibernate-configuration
 
 
 
  Do you have an idea?
 
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 


 --
 Pieter Degraeuwe
 Systemworks bvba
 Belgiëlaan 61
 9070 Destelbergen
 GSM: +32 (0)485/68.60.85
 Email: pieter.degrae...@systemworks.be
 visit us at http://www.systemworks.be





 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pieter Degraeuwe
Systemworks bvba
Belgiëlaan 61
9070 Destelbergen
GSM: +32 (0)485/68.60.85
Email: pieter.degrae...@systemworks.be
visit us at http://www.systemworks.be





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: org.hibernate.HibernateException: createCriteria is not valid without active transaction

2009-10-06 Thread Pieter Degraeuwe
a HibernateListener is something completely different.It is not required to
config a TransactionFactory in your config xml. There is implicitly always
one.. (if I remember well, since I always use Spring to configure my
Hibernate...)

I suggest that you look first to some hibernate examples, since these issues
are not related to wicket.



On Tue, Oct 6, 2009 at 9:53 AM, Peter Arnulf Lustig u...@yahoo.dewrote:

 ok!
 So I need  a listener class  like HibernateListener and a
 Transactionfactory in the config xml ?






 - Ursprüngliche Mail 
 Von: Pieter Degraeuwe pieter.degrae...@systemworks.be
 An: users@wicket.apache.org
 Gesendet: Dienstag, den 6. Oktober 2009, 09:49:42 Uhr
 Betreff: Re: org.hibernate.HibernateException: createCriteria is not valid
  without active transaction

 Indeed, when you start a transaction and get an object from the database,
 hibernate wil persist changes to that object when you transaction (and thus
 sesseion) is still open.
 This is normal behaviour.

 Note that it is in most cases a bad habit to use manual transaction
 management...

 On Tue, Oct 6, 2009 at 9:44 AM, Peter Arnulf Lustig u...@yahoo.de
 wrote:

  How can I do it manually?
 
 
  For example: I have a DataProvider class with a method:
 
  public static Administrator getAdministrator(Integer id) {
 Administrator administrator= (Administrator)
 
 HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(Administrator.class).add(Property.forName(id).eq(id)).uniqueResult();
 return administrator;
 
 }
 
 
  I get the error message. How shall I modify the code?
  I tried it with Transaction tx = ... and then tx.begin() tx.commit()  --
  but then suddenly hibernate tries permanently to update an object...
 wired !
 
 
 
 
  - Ursprüngliche Mail 
  Von: Pieter Degraeuwe pieter.degrae...@systemworks.be
  An: users@wicket.apache.org
  Gesendet: Dienstag, den 6. Oktober 2009, 09:29:58 Uhr
  Betreff: Re: org.hibernate.HibernateException: createCriteria is not
 valid
   without active transaction
 
  You did not setup your transactions properly.
  Or you start your transaction manually, or if you like spring, you can
 let
  spring manage it. (just add your transction annotations to your services,
  and, done !
 
  On Tue, Oct 6, 2009 at 9:15 AM, Peter Arnulf Lustig u...@yahoo.de
  wrote:
 
get this error always! I don't understand why.
  
   this is my hibernate.cfg.xml
  
  
   hibernate-configuration
session-factory name=session1
  property
   name=hibernate.dialectorg.hibernate.dialect.MySQLDialect/property
  property
  
 name=hibernate.connection.driver_classcom.mysql.jdbc.Driver/property
  property
  
 
 name=hibernate.connection.urljdbc:mysql://localhost:3306/mydb/property
  property name=hibernate.connection.usernameroot/property
  property
  
 
 name=hibernate.current_session_context_classorg.hibernate.context.ThreadLocalSessionContext/property
  mapping resource=org/omikron/test/data/Ticket.hbm.xml/
  mapping resource=org/omikron/test/data/Testprocedure.hbm.xml/
  mapping resource=org/omikron/test/data/Tag.hbm.xml/
  mapping resource=org/omikron/test/data/Testentity.hbm.xml/
  mapping resource=org/omikron/test/data/Questionset.hbm.xml/
  mapping resource=org/omikron/test/data/Administrator.hbm.xml/
  mapping resource=org/omikron/test/data/Systemsetting.hbm.xml/
  mapping resource=org/omikron/test/data/Question.hbm.xml/
/session-factory
   /hibernate-configuration
  
  
  
   Do you have an idea?
  
  
  
  
   -
   To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
   For additional commands, e-mail: users-h...@wicket.apache.org
  
  
 
 
  --
  Pieter Degraeuwe
  Systemworks bvba
  Belgiëlaan 61
  9070 Destelbergen
  GSM: +32 (0)485/68.60.85
  Email: pieter.degrae...@systemworks.be
  visit us at http://www.systemworks.be
 
 
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 


 --
 Pieter Degraeuwe
 Systemworks bvba
 Belgiëlaan 61
 9070 Destelbergen
 GSM: +32 (0)485/68.60.85
 Email: pieter.degrae...@systemworks.be
 visit us at http://www.systemworks.be





 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Pieter Degraeuwe
Systemworks bvba
Belgiëlaan 61
9070 Destelbergen
GSM: +32 (0)485/68.60.85
Email: pieter.degrae...@systemworks.be
visit us at http://www.systemworks.be