dao « DAO « JPA Q&A





1. Enumerations in Hibernate    stackoverflow.com

It is often useful to have a field in a DAO whose value comes from a Java enumeration. A typical example is a login DAO where you usually have a field ...

2. Solving JPA query finding the last entry in connected list    stackoverflow.com

Following class structure is given:

class Job 
{
    String description;
    Collection<JobHistory> history;
}

class JobHistory
{
    Date assignDate;
    User jobOwner;
}

class JobOwner 
{
  ...

3. Abstracting named queries in an abstract JPA DAO    stackoverflow.com

I have an abstract DAO class which uses parameterized types E (Entity) and K (Primary Key). In every entity I have a @NamedQuery. I want to dynamically invoke this named query ...

4. designing a hibernate dao    stackoverflow.com

I am using following code

 TestDAO {

    Session session = null;

    public TestDAO() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
  ...

5. how to check if an item with same name exists using dao,hibernate    stackoverflow.com

In a web app,I am letting the user create an Item.The db manipulations are done through dao implementations which use hibernate.The generic dao implementation uses Criteria for the query The name of ...

6. Hibernate DAO factory cannot instantiate dao    stackoverflow.com

I have a JSF 2.0/Servlet 3.0 Web application using hibernate with a connection pooled data source on glassfish 3. I tried using the DAO pattern as described in this tutorial:
GenericDataAccessObjects I ...

7. Multiple DAO instances = Bad?    stackoverflow.com

Two application (A and B) use hibernate to retrieve the same entities out of a database. Should a DAO be instantiated in each application or should there be a separate application ...

8. Why so many interfaces in JPA?    stackoverflow.com

Having a look at some JPA code and I see:

public interface Dao<T extends DomainObject>

public interface EventDao extends Dao<Event> - nothing added to Dao<Event>

public abstract class AbstractDaoJPAImpl<T extends DomainObject> extends JpaDaoSupport implements ...

9. Hibernate with DAO?    coderanch.com

Yes you can. Its a good idea too - in this case the DAO pattern will keep the actually implementing ORM technology in its own layer. If you suddenly decide you hate Hibernate, you could swap to a JDO implementation without impacting your application (beyond having to write DAOs for JDO...). The advantage Hibernate gives you in this case is you ...





10. hibernate and dao    coderanch.com

11. Hibernate over DAO    coderanch.com

12. JPA and DAO    coderanch.com

13. DAO by Hibernate reverse engineering    coderanch.com

15. diff between DAO and Hibernate    coderanch.com

16. DAO Implementation & Hibernate    coderanch.com

Can anyone make me clear about the advantages of using DAO framework over Hibernate framework.DAO being a Creational Pattern hides the database implementation details from the client but even Hibernate does the same and maintain easy migration from one database to another through change of dialects.I have seen some implementing DAO Pattern along with Hibernate, which i dont get to understand ...





17. JPA and DAO's    coderanch.com

Today I was messing around with JPA a bit again, you know, just for fun, because I'm such a big freggin dork. Anyway, my typical pattern for data access is to use DAO's for general queries and a service (business) layer that uses the DAO's and might wrap several queries in a transaction or in general take care of some nastiness ...

19. new to Hibernate DAO    coderanch.com

20. DAO instance    forum.hibernate.org

21. Hibernate DAO best practices    forum.hibernate.org

I am working on creating a library that contains entities and DAO for a database. Most examples/tutorials I have seen do not have any notion of transactions in them. Is this because the calling application should wrap the DAO method calls in the beingTransaction(), commit() / rollback() code, or is there an easier way to do things? I have looked in ...

22. Coding the Dao for a many-to-many coded as two many-to-one    forum.hibernate.org

Pro Joined: Mon Apr 16, 2007 8:10 am Posts: 213 Hello, I'm trying to fix a Dao method on a many to many relationship coded as two many-to-one relationships. I have a test case that goes like this: Code: @Test public void testFindByMailList() { mailList0 = new MailList(); ...

23. Spell out DAO w/Hibernate & lazy initialization implicat    forum.hibernate.org

People apparently use Hibernate with the DAO pattern but it looks like some ppl have trouble with lazy initialization--perhaps because of their implementation. Could someone please layout the implications of using DAO and lazy initialization and offer some basic guidelines for implementation or just enumerate the major related pitfalls? Thanks, Sean Gunn

24. DAO implementations    forum.hibernate.org

One simple ... [code] public class User { private int id; private String login; private String password; private String name; ...... private Set groups; private Set companies; } public class HibernateUserDAO { private HibernateFactory factory; public HibernateUserDAO() { factory = HibernateFactory.getInstance(); } public User select(int id) throws HibernateException { User res = null; Session session = null; try { session = ...

25. Hibernated DAOs and serialization: best practices?    forum.hibernate.org

What is the interaction between Hibernate classes and Java serialization? We would like to write (for instance) session beans with interfaces such as: public List getClients(); which would return a List of Client objects fetched on the server with session.find("from Client"); Eventually, each Client object will have a lazy list of Campaign objects (a standard lazy parent-child mapping where Client is ...

26. To DAO or not    forum.hibernate.org

If I understand DAOs correctly (and if I don't, please enlighten me) it seems most of the functionality usually implemented in a DAO is covered by the Hibernate API. By this I mean finders, loading, saving etc. If I decide that it is not important to me abstract the persistence mechanism to make it easy to swap out (after all Hibernate ...

27. DAO-and hibernate    forum.hibernate.org

28. dao architechture advice    forum.hibernate.org

hi: I am implementing a session beans -> dao - > hibernate architechture. I wanted to know what is a better idea to have a DAO / persistent class or have a DAO serving a group of logically related persistent classes. I was prefering the latter as we have a large number of persistent classes.Any advantages to the first approach ? ...

29. Other DAO implementations.    forum.hibernate.org

30. DAO Vs ORM    forum.hibernate.org

i think depending people, the doc or a commercial support is needed, all my team is really waiting for the book (real book with paper). I'm also advising an off-shore partner to contact you for a commercial support since i want them to know all about hibernate and best practices. i don't wanna have bad surprises during test phase

31. DAO's: Need some clarification on best use/practice    forum.hibernate.org

I get the power of O/R mapping, and I get the power of abstracting the interface to the O/R mapper. After reading as much as I can about the DAO pattern, I get the benefit of it -- not only abstract access to an O/R tool, but abstract access to any DataSource. So it seems that the pattern is to create ...

32. Best practice to implement a DAO using Webwork    forum.hibernate.org

33. DAOs, LazyInitialization, loading levels: Best Practice    forum.hibernate.org

I'm curious to know how others are dealing with this issue: You want an entity, A, that has associations to B and C. One use case requires that you return just A, another requires you return A w/ Bs, another A w/ Cs. In the scenarios above, how'd your DAO method(s) look? That is, do you have DAO methods for each ...

34. Any sense in making 2 sets of DAOs - Hibernate & normal    forum.hibernate.org

Hi there I am wondering - have you ever encountered situation, when you want to do something more than simple CRUD ? For example joining some tables, counting sth and then put that in the databean ? Cause as far as I know you cannot do that in simply and elegand manner in Hibernate. So will finish with two sets of ...

35. DAO and Hiberate    forum.hibernate.org

36. What is the difference between DAO and ORM    forum.hibernate.org

Hi, I am really questioning the usage of a DAO layer in a J2EE app where you have also a business service layer and a ORM solution. DAO's main purpose is to shield developers from the SQL ,seperate the logic and the data. So when using hibernate or whatsoever, you are duplicating nearly the same code.

37. Hibernate DAOs Standalone    forum.hibernate.org

This thread is actually a continuation of the following topic: Hibernate DAOs Standalone vs. J2EE Environments http://forum.hibernate.org/viewtopic.php?t=946551 i started a new thread so that i can hand out a few credit points, since i would really need to understand this asap... ---------------------- i am currently trying to combine christians "Generic DAO pattern with JDK 5.0" with a standalone application. since the ...

38. Multiple DAOs neccessary?    forum.hibernate.org

I'm just wanting to get the opinion of some of you folks experienced with this before I go off doing something that might be really dumb. It seems to be standard practice to use a different DAO for each class you need stored in a database. I understand the reason for this in most cases, but hibernate allows you to find ...

39. DAO Implimentation    forum.hibernate.org

I also have some questions on what the two following methods do: [code] public T makePersistent(T entity) public void makeTransient(T entity) [/code] I can understand that makePersistent is saving the state of the object within the database. makeTransient calls a delete method. Does that mean that the object looses it's connection with the database? I can not figure out why this ...

40. OpenSessionInViewFilter and DAO    forum.hibernate.org

Hi, as a newbie of Hibernate and ORM in general I would need to have the behaviour of entity persistance and OpenSessionInView clarified. I understand that: - openSessionInViewFilter mantains the same session opened for the lifecycle of the request. - according to the documentation, I understand that within the same hibernate session objects are persisted automatically, which means with no need ...

41. Using DAOs    forum.hibernate.org

Hi, DAOs are abstracting from Hibernate-specific data access code. I have two questions on abstracting from other Hibernate-specific code: 1. What is the recommended approach for abstracting from Hibernate-specific session and transaction code in a J2SE (non-Web) environment ? 2. What is the recommended approach for abstracting paging in a J2SE / J2EE environment (implementing a specific Paging class as mentioned ...

42. Dao access in a UserType    forum.hibernate.org

According to the following article, I18N data with hibernate, I'm implementing a usertype that access to an Hibernate style DAO to retrieve the code or the text of the loclalized label. My usertype nullSafeGet and nullSafeSet methods are like this : Code: public Object nullSafeGet(ResultSet rs, String[] names, Object owner) ...

43. my DAO is broken, anyone have one that works?    forum.hibernate.org

Author Message lloyd.mcclendon Post subject: my DAO is broken, anyone have one that works? Posted: Sat Aug 19, 2006 8:13 pm Beginner Joined: Sat Aug 19, 2006 8:04 pm Posts: 30 hi, i'm using hibernate and it is one of the best things ever. the other guys at work spend so much time dealing with databases, i don't even ...

44. my DAO is broken, anyone have one that works?    forum.hibernate.org

Author Message lloyd.mcclendon Post subject: my DAO is broken, anyone have one that works? Posted: Sat Aug 19, 2006 8:14 pm Beginner Joined: Sat Aug 19, 2006 8:04 pm Posts: 30 hi, i'm using hibernate and it is one of the best things ever. the other guys at work spend so much time dealing with databases, i don't even ...

45. DAOs and lazy loading best practice    forum.hibernate.org

What is the best practice for using lazy loading in a DAO? I currently have a DAO which opens/closes a new session for each operation. This works fine, but for performance reasons, we've now had to enable lazy loading for some collections. To avoid LazyInitizationException, I've been experimenting with a modified OpenSessionInView pattern: At the start of a request. a session ...

46. Querying DAOs with Set    forum.hibernate.org

I have a class called User and with a criteria search I make some User queries.... All users from the query where unique...nobody appeared several times. Then I added the method public Set getPictures(); and all the previous queries now returned some sort of joined resultset where usernames appeared several times...... So I added: criteria.setFetchMode("pictures", FetchMode.SELECT); to every query and it ...

47. Hibernate Vs DAO    forum.hibernate.org

Hello Experts, We have started a project using DAO. We came thru the some better features of hibernate. For instance data migration can be done with much more ease in hibernate rather than in DAO. Some said hibernate does not supports all queries of mysql. Is it true? We are struck with these statements. Anybody pls suggest which is better to ...

48. DAO and findById()    forum.hibernate.org

If you don't want your code to be mess by session open / close think using a declarative transaction layer like ejb container or spring. I am using spring with hibernate and it works like a charm. You don't have to take care on session open/close With your solution what would you do when you will have inter dao calls ? ...

49. One Hibernate DAO per table    forum.hibernate.org

Hi All, I would want to know what is ideal implementation in real world scenarios. Is it a popular practice to have one Hibernate DAO (entity based) per Hibernate Domain object or we can have a few DAO's (functionality based) catering to multiple Hibernate Domain objects. When to adopt which approach is what we are looking at the moment. Do post ...

50. put hbm, dao file and pojo in a jar    forum.hibernate.org

51. Should DAO be singleton???    forum.hibernate.org

52. How to get the instance of my DAO?    forum.hibernate.org

When my object is loaded (this is done automatically via objects cascading), how can it retrieve the instance of the DAO it should use? I suppose it could implement ILifecycle interface but having a reference to an ISession is not enought. I need the instance of my own DAO class. Is there a member variable of type object in ISession I ...

53. How to implement DAO for One-To-Many?    forum.hibernate.org

Hibernate version: not sure Mapping documents: Code: ...

54. DAO Exeption Handling    forum.hibernate.org

I have a question regarding (Generic Data Access Objects) http://www.hibernate.org/328.html Specifically, the line about not forgetting exception handling: // Plain JDBC: HibernateUtil.getCurrentSession().getTransaction().commit(); // Don't forget exception handling I've implement the examples described in the URL above (everything works perfectly), but have yet to add exception handling. How do I add hibernate exception handling to this block of code? Is it needed? ...

55. Naming tables in dao    forum.hibernate.org

public class UserLogDaoImpl implements UserLogDao { private static final String TABLE_NAME = "UserLog"; public List getLogsByUsername(String username, int i){ Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List logs = session.createQuery("select l from TABLE_NAME as l where l.username=:u").setMaxResults(i).setString("u", username).list(); session.getTransaction().commit(); ...

56. Confusion regarding adding fields in DAO & implementing    forum.hibernate.org

Hello, I am new to Hibernate & really having great trouble in understanding some issues. My questions are: i) Suppose I add some extra methods & fields in a particular DAO class & for some rows of the corresponding table I instantiate the Class & put them in some kind of collection. Now if I call the load() or get() method, ...

57. One DAO with multiple CFG files    forum.hibernate.org

DB2 - Websphere 6.1 - java 1.5 I'm trying to implement something that I'm afraid is going to slow my application down, but wanted to see if there was a good way to do this. The database is already built and being used by more people then just me, so changing the database structure or tables is a last resort. I ...