[SOLVED] ZATS + Hibernate

asked 2014-03-28 07:58:34 +0800

IngoB gravatar image IngoB flag of Germany
256 6

updated 2014-03-28 15:22:09 +0800


I want to test my GUI with ZATS.

So for my first testcase I wanted to login with "no credentials", to test if "Wrong Login" message appears.

Since i never worked with ZATS, i tried the tutorial/getting started

(The example testcase is 1:1 my testcase, except that Hibernate is looking up the credentials)

JUnit Code:

public void emptylogin() {
    DesktopAgent desktop = Zats.newClient().connect("/view/login/Login.zul");
ComponentAgent lblMsg = desktop.query("label");
ComponentAgent btnLogin = desktop.query("button");


assertEquals("Name or Password is invalid", lblMsg.as(Label.class).getValue());


Java Code:

 org.hibernate.Session hbnsession = HibernateUtil.getSessionFactory().getCurrentSession();
        Query query = hbnsession.createQuery("from User where login_name = :name");
        query.setString("name", name);
        User tempUser = (User) query.uniqueResult();

And there is my problem. When the button is clicked, he throws

org.hibernate.HibernateException: createQuery is not valid without active transaction

My ZK project is working fine, verifies the login, so the code is working, but ZATS/JUnit can't get a valid session.

How do I solve this?

P.S.: ZK 7.0.1 / ZATS 1.2.0

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-03-28 15:21:52 +0800

IngoB gravatar image IngoB flag of Germany
256 6

I solved it ...

I had to open a new Session, instead of using the current one.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2014-03-28 07:58:34 +0800

Seen: 11 times

Last updated: Mar 28 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More