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: Can I have hibernate load complete table
PostPosted: Fri May 16, 2008 12:52 pm 
Newbie

Joined: Wed May 24, 2006 4:40 pm
Posts: 10
How would I do this without a DAO:

Code:
public class Currencies {
    private Collection<Currency> currencies;
    // getter and setter
}

@Entity @Table(name="currency_data")
public class Currency {
    @Id @Column private Integer number;
    @Column private String name;
    // getters and setters
}


Is there a setup, using which hibernate can load all currencies on: "new Currencies().getCurrencies()".
A JPA solution would be good to have, but not a requirement.

I have this currently working as (using DAO):
Code:
    public Currencies loadTable() {
        final EntityManager em = PersistenceHelper.getEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();
        try {
            Collection<Currency> cs = em.createQuery("from Currency").getResultList();
            return new Currencies(cs);
        }
        finally {
            tx.rollback(); // read-only
        }
    }


Hibernate version: 3.2
Mapping documents: annotations 3.3.1 / hibernate entity manager 3.3.2

Requirement:
We use Coherence caching solution. This data needs to be in cache as a single object (Collection of all currencies).
I am trying to setup cache configuration to use JPA so that whenever it needs something from the database, cache can itself use JPA to get it.

Any help / pointers would be greatly appreciated.

Ajay

_________________
http://www.ajaygautam.com/


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 16, 2008 2:08 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
what is it that you don't like in your DAO exactly?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 17, 2008 8:18 am 
Newbie

Joined: Wed May 24, 2006 4:40 pm
Posts: 10
I love the DAO. Nothing wrong with it. The point here is to see if we can do this without a DAO.

I am in a a situation where the DAO will not be called: The deployment is: hibernate as a plugin to another product (Oracle's coherence). There is no way to specify that the other product should call a DAO (or atleast I couldn't find one).

Wondering if there is a way in hibernate to do this.

Does any of this makes sense?

Ajay

_________________
http://www.ajaygautam.com/


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.