Announcement Announcement Module
Collapse
No announcement yet.
Spring + hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    can any one help me ?!!!!!!!!!!!!!!!!!!!!!!!!

    Comment


    • #17
      Hello
      I still waiting for the response

      ------------
      Blacky

      Comment


      • #18
        Hello, tried the same configuration and it worked.

        Only changes i did was using hsql db and following,

        Code:
        	public static void main(String[] args) {
        		// TODO Auto-generated method stub
        		BasicDataSource mds=(BasicDataSource) (new XmlBeanFactory(new ClassPathResource("appco.xml")).getBean("myDataSource"));
        		SessionFactory lse= (SessionFactory) (new XmlBeanFactory(new ClassPathResource("appco.xml")).getBean("sessionFactory"));
        
        		System.out.println("Hello");
        	}
        Please post your applicationContext.xml too

        Comment


        • #19
          Hello
          you can see the configuration context file
          at the begining of this therad
          http://forum.springsource.org/showth...ring-hibernate

          i want to use the AnnotaionSessionFactoryBean class
          is there any other solution ?

          thank you
          ----------------
          Blacky

          Comment


          • #20
            I used AnnotationSessionFactoryBean and it works.

            Exception in thread "main" java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to org.springframework.orm.hibernate3.annotation.Anno tationSessionFactoryBean
            at m.Main.main(Main.java:18)
            Above exception comes because of invalid casting.

            What is the reason you want to get AnnotationSessionFactoryBean from context?

            Comment


            • #21
              Originally posted by amiladomingo View Post
              I used AnnotationSessionFactoryBean and it works.



              Above exception comes because of invalid casting.

              What is the reason you want to get AnnotationSessionFactoryBean from context?
              can you post the project that you realize with all the jars that you use

              i haven't a very important reason, but i want that because i have encountred this exception and i saw many examples which the author use the AnnotationSessionFactoryBean.

              thank you for the reply

              ---------------
              Blacky

              Comment


              • #22
                Ahh you want to retrieve the FactoryBean and not the object. Then you need to prefix the name with &. (i.e. '&sessionFactory')

                Comment


                • #23
                  Originally posted by amiladomingo View Post
                  Ahh you want to retrieve the FactoryBean and not the object. Then you need to prefix the name with &. (i.e. '&sessionFactory')
                  Hello thank you very very very and 1000000000000000000000000000000000000^999999999999 999999999999999999999 very much
                  it worked very well
                  this tric, its a magic, can you tell me why, i would to know why we must add this littale prefix ?

                  can you give me the final help

                  ------------------
                  Blacky

                  Comment


                  • #24
                    From spring reference,

                    When you need to ask a container for an actual FactoryBean instance itself, not the bean it produces, you preface the bean id with the ampersand symbol & (without quotes) when calling the getBean() method of the ApplicationContext. So for a given FactoryBean with an id of myBean, invoking getBean("myBean") on the container returns the product of the FactoryBean, and invoking getBean("&myBean") returns the FactoryBean instance itself.
                    Note that, AnnotationSessionFactoryBean class implements the spring FactoryBean interface.

                    Comment


                    • #25
                      Thank you very much

                      ------------
                      Blacky

                      Comment

                      Working...
                      X