Cosme Fulanito

Greenhorn
+ Follow
since Dec 19, 2014
Cosme likes ...
Eclipse IDE Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cosme Fulanito

UPDATE:
I did everything again, calling my method with the Controller now it works, but I found that using the web service don't.
Apparently when calling the WSDL is created an instance and that is making everything Null.

Do you know how can I do this? because in other way I will have to create manually my SessionFactory objet using a kind of Hibernate helper.
9 years ago
This @Service is being called from the web service, so I don't do anything similar to new, also if I call the same method from a Controller I still get the same problem, very annoying.
9 years ago
I got it, but still is not working, getting null when I call my class via Autowired.

This is what I'm calling via Axis



That's it.

Don't get upset if I say that don't worry aout Axis or for what else can be saying the stack trace, you know that when is throwed an exception is a kind of inverse cascade, so it always point to this class with the Null
9 years ago
Hi,
I found something about this, finally I can get the sessionFactory object but whit a weird behavior.
Normally I'm calling the DAO in this way:

Declaring in my controller class a tipe of my Dao

@Autowired
private myDao myDao; // where "myDao" is actually the interface

and then when I need it I create using

myDao = new myDaoImpl();
myDao.myMethod();

What I found is that using the "new" declaration my sessionFactory returns null, but if just calling the method, everything is ok.

But not all is great, because if I use the same code in other class (intermediate class with @Component annotation) the myDao needs to be initializated using new... and then again sessionFactory null.

Don't worry about Axis, in my test I did a web service who is calling the method, the stack trace doesn't say too much, just the NullPointerException.
9 years ago
Hi Jayesh, in the other post I show a Dao who extends the GenericDao and the way how I try to call the sessionFactory.
A brief summary about what I'm doing is: creating a bean in the XML using the Spring class org.springframework.orm.hibernate4.LocalSessionFactoryBean, which should create a new session factory object, so in that order I use the Autowired annotation to inject it to my GenericDao, but always getting null, aparently it is not being created.

9 years ago
As an update, until now nothing happens.
Still I don't understand why the SessionFactory is not being injected or initialized.
9 years ago
By the way, I found this about HibernateDAOSupport http://stackoverflow.com/a/5104965
9 years ago
Hi Jayesh!
As I said I'm new with this, right now I'm checking HibernateDAOSupport, some advice about it?

I'm using injection by annotations, in my DAO bean I have something like this:



Can you point me what more I need to put in my servlet-context? As I see comparing to tutorials it is fine, the bean SessionFactory is declared and injected into de GenericDao.

Regards!
9 years ago
Be sure that you have all dependencies. Are you using Maven?
9 years ago
Hi everyone,
I'm a newbie in the Spring enviroment but I have been reading a lot about how it works.
By now I'm doing a simple project with Hibernate, so here is where things goes interesting.
In the servlet-context file I have something like this:



And I have an abstract class (In order to extend it over all my DAO implementations) that looks like this:



Doing this when I need create a new method, all that I do in my other DAO is create a local variable with type Session and set the getSessionFactory().getCurrentSession().

I have been testing the connection credentials in order to validate the dataSource, anyway always that I try to obtain the Session I got null

What can I be loosing in my configuration?


Reggards!
9 years ago