your blogpost helped this code below did the job, thx


private SessionFactory sessionFactory;
        
public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
}
public void save(String modelName, x values){
        log.debug( values );
                
GenericDaoHibernate<X,Long> genericDao = new GenericDaoHibernate<X, Long>(X.class);
        genericDao.setSessionFactory(sessionFactory);
                
        log.debug(genericDao.get(-1L).getName());

with:

<bean id="xxxDWRManager" class="....XxxDWRManagerImpl" >
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

well i have the feeling that this is not quite the right way to go.
But well i can now use reflections to change the persistentClass to anything.

thx again.
lg:nils


On Sep 25, 2009, at 4:54 PM, Matt Raible wrote:

This post and its comments might be useful:

http://raibledesigns.com/rd/entry/moving_from_spring_s_xml

Matt

On Fri, Sep 25, 2009 at 7:37 AM, Nils Petersohn <n...@schoenhouse.de> wrote:
hello,
i try to implement a generic type of instantiating the genericManager.
for this i need to call the getBean Method from the BeanFactory:
Resource res = new FileSystemResource(".../WEB-INF/ applicationContext.xml");
BeanFactory factory = new XmlBeanFactory(res);
GenericManager<MyClass,Long> x  =
(GenericManager<MyClass,Long>)factory.getBean("&myClassManager");
i know that this is not the way of IOC but for my generic approach this is
the only way i guess.
the MyClass should than be changed via reflection and also the getBean
parameter.
the tree lines above work so far but the genericManager has the bean
property sessionFactory.
it than gives me the exception:
is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'sessionFactory' is defined.

at this post someone calls the method autowireBeanProperties which has the
third parameter for boolean dependencyCheck
http://stackoverflow.com/questions/812415/why-is-springs-applicationcontext-getbean-considered-bad/1388938#1388938
but i don't understand that right ...
is there a better way to do this??
thanks


Nils M. Petersohn
snackycracky.wordpress.com
xing.com/profile/Nils_Petersohn
myspace.com/electrash
twitter.com/snackycracky
facebook.com/nils.petersohn
n...@schoenhouse.de
0049 (0)177 6311074
skype: nilz_berlin
icq: 99510895
Ebertystr. 47
10249 Berlin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Nils M. Petersohn
snackycracky.wordpress.com
xing.com/profile/Nils_Petersohn
myspace.com/electrash
twitter.com/snackycracky
facebook.com/nils.petersohn

n...@schoenhouse.de
0049 (0)177 6311074
skype: nilz_berlin
icq: 99510895

Ebertystr. 47
10249 Berlin

Reply via email to