I wrote an APT processor that finds all @Entity-annotated classes and
adds them to a hibernate.cfg.xml file. If you're interested, let me
know.
On 11/16/07, Edward Sumerfield <esumerfd@xxxxxxxxxxxxxx> wrote:
> Two questions today:
>
> 1) I have hibernate 3 annotations buzzing along just fine all configured in
> Spring 2 but, being a lazy fellow, I don't want to have to add every entity
> into the Spring config file. Instead, I would like an autodiscovery
> mechanism to find the @Entity annotated classes and add them to Spring
> config automatically.
>
> Before I go off an write such a thing perhaps someone knows of an existing
> solution.
>
> <property name="annotatedClasses">
> <list>
> <value>org.acme.entity.Customer </value>
> </list>
> </property>
>
> 2) I am using the HibernateDaoSupport class and so have two beans configured
> for every Dao that I write. Is there a simple way to condense the bean
> declarations needed to add a Dao? This is what I have at the moment for a
> single Dao and the only difference between Daos is the word "Acme", all the
> rest is vanilla template code.
>
> Is there a simpler way than code generation?
>
> <bean
> id="acmeDaoTarget"
> class="org.acme.dao.AcmeDaoImpl"
> autowire="byName" />
>
> <bean
> id="org.acme.dao.AcmeDao"
>
> class="org.springframework.aop.framework.ProxyFactoryBean">
> <property name="proxyInterfaces">
> <value> org.acme.dao.AcmeDao</value>
> </property>
> <property name="interceptorNames">
> <list>
> <value>hibernateInterceptor</value>
> <value>acmeDaoTarget</value>
> </list>
> </property>
> </bean>
>
> --
> Ed
>
|