|
From: <jue...@we...> - 2004-06-16 11:16:49
|
Simply expose a bean property of type LocalSessionFactoryBean and define =
a declarative bean reference:
<bean id=3D"myDao" class=3D"mypackage.MyDaoImpl">
<property name=3D"sessionFactory"><ref =
bean=3D"sessionFactory"/></property>
<property name=3D"localSessionFactoryBean"><ref =
bean=3D"&sessionFactory"/></property>
</bean>
public class MyDaoImpl {
public void setSessionFactory(SessionFactory sessionFactory) {
...
}
public void setLocalSessionFactoryBean(LocalSessionFactoryBean lsfb) {
...
}
...
}
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf
Of snpe
Sent: Wednesday, June 16, 2004 2:45 PM
To: spr...@li...
Subject: Re: [Springframework-developer] Hibernate Configuration and
SessionFactory
Juergen,
getBean("&sessionFactory") work fine - I need Configuration for =
database properties for instance :
table name, column name and special column length
What mean : 'This will also work via a bean reference ' - How use it ?
Thanks
On Wednesday 16 June 2004 07:37 am, j=FCrgen h=F6ller [werk3AT] wrote:
> HibernateDaoSupport's protected accessors should usually be good =
enough - they allow access in subclasses, which is what you typically =
want.
> =20
> Regarding the Configuration object: You can fetch the =
LocalSessionFactoryBean itself via getBean("&sessionFactory"),
> i.e. a prefixed "&" to get the FactoryBean itself rather than the =
SessionFactory it creates. This will also work via a bean reference.=20
> =20
> The standard HibernateDaoSupport base class shouldn't have a =
Configuration property, I believe, as this is hardly ever needed. I =
suggest to expose a separate property of type LocalSessionFactoryBean in =
your DAO class, pass "&sessionFactory" in, and fetch the Configuration =
object from there.
> =20
> Juergen
> =20
>=20
> ________________________________
>=20
> Von: spr...@li... im Auftrag =
von snpe
> Gesendet: Mi 16.06.2004 06:58
> An: spr...@li...
> Betreff: Re: [Springframework-developer] Hibernate Configuration and =
SessionFactory
>=20
>=20
>=20
> Hi Dmitriy,
> You are correect - I use spring 1.0.1, but I have current cvs
> There is public method getConfiguration in LocalSessionFactoryBean, =
but I don't know how I can get instance this class
>=20
> I can get hibernate metadata from SessionFactory, but I can't get =
database metadata (for instance length) without Configuration
>=20
> Is it possible export Configuration to HibernateDaoSupport ?
>=20
> Is current cvs stable or I have to checkout version 1.0.2 ?
>=20
> Thanks
> On Wednesday 16 June 2004 03:17 am, Dmitriy Kopylenko wrote:
> > Haris,
> >
> > what version of Spring are you using? As of 1.0.2 the visibility of
> > HibernateDaoSupport's resource factory accessors has been changed to
> > *public*.
> >
> > I'm not sure about how you would get hold of Configuration instance =
though.
> >
> > Regards,
> > Dmitriy.
> >
> >
> > snpe wrote:
> >
> > >Hello,
> > > I want use SessionFactory and Configuration classes for metadata =
API (property name type, database name, type, length etc)
> > >I use spring's HibernateDaoSupport, but getSessionFactory is =
protected and I can't use it in my DAO (why ? - I can make method for =
get SessionFactory,
> > >but I don't know why this is protected/forbiden)
> > >
> > >How I get instance classes Configuration and SessionFactory ?
> > >
> > >regards
> > >Haris Peco
> > >
> > >
> > >-------------------------------------------------------
> > >This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> > >Learn from the experts at JavaOne(SM), Sun's Worldwide Java =
Developer
> > >Conference, June 28 - July 1 at the Moscone Center in San =
Francisco, CA
> > >REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code =
NWMGYKND
> > >_______________________________________________
> > >Springframework-developer mailing list
> > >Spr...@li...
> > =
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
> > >=20
> > >
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> > Learn from the experts at JavaOne(SM), Sun's Worldwide Java =
Developer
> > Conference, June 28 - July 1 at the Moscone Center in San Francisco, =
CA
> > REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code =
NWMGYKND
> > _______________________________________________
> > Springframework-developer mailing list
> > Spr...@li...
> > =
https://lists.sourceforge.net/lists/listinfo/springframework-developer
> >
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San Francisco, =
CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code =
NWMGYKND
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>=20
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San Francisco, =
CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code =
NWMGYKND
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>=20
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|