-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problems with initializing proxy
PostPosted: Sun Sep 14, 2008 1:41 pm 
Newbie

Joined: Sun Sep 14, 2008 1:35 pm
Posts: 8
Hibernate version: 3

Hi. I have a problem with my first hibernate application.

Code: http://www.javabeat.net/articles/42-int ... ewo-1.html


Errors: http://pastebin.com/m23c2da2


I'm using mysql.

I don't know why there is some problems with initializing proxy.

I'd be very thankful for help !


EDIT:

And I can tell that this error throws when I'm try to print empResult object !
Code:
System.out.println(empResult.getAge());


Something wront is with getEmpolyee() function. saveOrUpdate function is OK (rows are corectly saved in databse) Can anyboyd help me ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2008 3:31 pm 
Newbie

Joined: Sun Sep 14, 2008 1:35 pm
Posts: 8
I've changed EmployeeDao class for simpler version:

Code:
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
import java.util.List;

public class EmployeeDao {

    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate){
        this.hibernateTemplate = hibernateTemplate;
    }

    public HibernateTemplate getHibernateTemplate(){
        return hibernateTemplate;
    }

    public Employee getEmployee(Integer id){       
       return (Employee) this.hibernateTemplate.load(Employee.class, id);
       //List<Employee> results = hibernateTemplate.find("from Employee where id = " + id);
       //return results.size() > 0 ? results.get(0) : null;
    }


    public void saveOrUpdate(final Employee employee){
       hibernateTemplate.saveOrUpdate(employee);
    }
}


But there is the same problem. I've tried to use find function :
Code:
List<Employee> results = hibernateTemplate.find("from Employee where id = " + id);
       return results.size() > 0 ? results.get(0) : null;
and in this version everything is OK ! I don't know where is the problem. Maybe with Employee.class ?

Can somebody help me ? PLZ


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2008 3:35 pm 
Newbie

Joined: Sun Sep 14, 2008 1:35 pm
Posts: 8
I've changed EmployeeDao class for simpler version:

Code:
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
import java.util.List;

public class EmployeeDao {

    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate){
        this.hibernateTemplate = hibernateTemplate;
    }

    public HibernateTemplate getHibernateTemplate(){
        return hibernateTemplate;
    }

    public Employee getEmployee(Integer id){       
       return (Employee) this.hibernateTemplate.load(Employee.class, id);
       //List<Employee> results = hibernateTemplate.find("from Employee where id = " + id);
       //return results.size() > 0 ? results.get(0) : null;
    }


    public void saveOrUpdate(final Employee employee){
       hibernateTemplate.saveOrUpdate(employee);
    }
}


But there is the same problem. I've tried to use find function :
Code:
List<Employee> results = hibernateTemplate.find("from Employee where id = " + id);
       return results.size() > 0 ? results.get(0) : null;
and in this version everything is OK ! I don't know where is the problem. Maybe with Employee.class ?

Can somebody help me ? PLZ


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.