users
[Top] [All Lists]

Re: [cinjug-users] Hibernate Annotation Autodiscovery and Autoconfigurat

To: esumerfd@xxxxxxxxxxxxxx, "users@xxxxxxxxxx" <users@xxxxxxxxxx>
Subject: Re: [cinjug-users] Hibernate Annotation Autodiscovery and Autoconfiguration
From: "James Carman" <james@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Nov 2007 08:53:16 -0500
Delivered-to: mailing list users@xxxxxxxxxx
In-reply-to: <6a216ba20711160535y1e5b93e9ma90efc7ef416fe19@xxxxxxxxxxxxxx>
Mailing-list: contact users-help@xxxxxxxxxx; run by ezmlm
References: <6a216ba20711160535y1e5b93e9ma90efc7ef416fe19@xxxxxxxxxxxxxx>
Sender: jcarman@xxxxxxxxxxxxxxxxxxxx
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
>

<Prev in Thread] Current Thread [Next in Thread>