On 5/4/07, tibi <[EMAIL PROTECTED]> wrote:
i have two question about http://appfuse.org/display/APF/Using+Hibernate one is in application context is should enter this: <bean id="personDao" class=" org.appfuse.dao.hibernate.GenericDaoHibernate"> <constructor-arg value="org.appfuse.tutorial.model.Person"/> <property name="sessionFactory" ref="sessionFactory"/> </bean> but the constructor is: public PersonDaoHibernate() { super(Person.class); }
The tutorial covers 2 scenarios: 1) You only need to do CRUD on the Person object, in which case there is no need to create a custom DAO - you simply use the Generic DAO which is the config you quote above. 2) You need CRUD as well as some custom finder functionality for your Person object: in this case you need to code your own DAO which extends the Generic DAO. If you do this the declaration in your Spring config file will be for your new class, which, as you point out does not require a constructor argument. The correct configuration snippet for such a case is included at the end of the tutorial. so i gues the contructor argument is not needed.
when i run this from my test its fine when i use this from my app i get: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. which i now understand is because it is not called manager and will not be raped in a transaction. what should i do name it manager or change some config somewhare??
It all depends on how you access your DAO from your web pages. Normally you only access your DAO through a manager class, which is where the transactions get started. If you want your DAO to be transactioned, you can either add the annotation @Transaction or change the Spring config to explicitly add transactions to your DAO. Mike. thanks
tibi --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
