Announcement Announcement Module
Collapse
No announcement yet.
Equivalent HibernateTemplate.loadAll(entityClass) method in JpaTemplate/Callback? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Equivalent HibernateTemplate.loadAll(entityClass) method in JpaTemplate/Callback?

    Hi,
    I am trying to return a list of all domain objects of a specific class using the JpaTemplate. I don't mind using a JpaCallback to use the EntityManager to acheive the same thing, but can't find something obvious. I am using OpenJpa but would like to keep this transparent, ie, just use the javax.persistence.EntityManager methods if possible, but don't mind using any lower level OpenJpa methods either if this is not possible.

    I can retrieve a list of domain objects using a supplied domain object class and identifiers (as this is a method on the JpaTemplate), but I just want to specify the class without the idenfiers to get all objects. Any suggestions?
    Thanks
    Alan

  • #2
    Couldn't you just pass the query String into the find method instead? e.g. "from MyEntity".
    Last edited by karldmoore; Aug 27th, 2007, 03:16 PM.

    Comment


    • #3
      Like this (I can't test it yet as I haven't set up all the rest of my Sping/JPA infrastructure)?
      Code:
      	public List findAll(Class domainObjectClazz) throws DataAccessException {
      		return getJpaTemplate().find("from " + domainObjectClazz.getName());
      	}
      Alan
      Last edited by Alan Stewart; Jul 25th, 2007, 11:01 PM. Reason: typos

      Comment


      • #4
        Well, it's only a guess..... I'm still thumbing through the new Hibernate book myself. It would work with Hibernate so I guess it should work with JPA.
        Last edited by karldmoore; Aug 27th, 2007, 03:16 PM.

        Comment


        • #5
          I'll post back my progress. I'm writing a JPA "Repository" implementation for Ben Alex's ROO (domain-driven design) framework. I'm testing it with OpenJpa, but so far all the methods I have replicated from the Hibernate Repository version are JPA-agnostic, which is good, as I don't have to write any JPA callbacks to get to the underlying JPA implementation. Theoretically, I should only have to change the Spring context xml to use a different JPA implementation.
          Alan

          Comment


          • #6
            WOW, you've managed to get your hands on ROO???????
            Last edited by karldmoore; Aug 27th, 2007, 03:16 PM.

            Comment


            • #7
              Uhmmm, yes.
              I work for Woolworths in Sydney and we got Ben in do some consulting for us last October when ROO was in its infancy. I've got two projects in production using ROO now and have contributed to the code base where I can.

              I am trying to get Ben back again to do some more (funded) work on it to help fast track it to become open-sourced, but the wheels turn very slowly here.
              Cheers
              Alan Stewart

              Comment


              • #8
                Originally posted by aks View Post
                I work for Woolworths in Sydney and we got Ben in do some consulting for us last October when ROO was in its infancy. I've got two projects in production using ROO now and have contributed to the code base where I can.
                Ahh ok that makes, sense! You're one of the lucky ones that gets to play with this stuff then . There are quite a few of us looking forward to having a play with the code.

                Originally posted by aks View Post
                I am trying to get Ben back again to do some more (funded) work on it to help fast track it to become open-sourced, but the wheels turn very slowly here.
                I think that's just companies in general.
                Last edited by karldmoore; Aug 27th, 2007, 03:16 PM.

                Comment

                Working...
                X