All posts tagged ejb

  • Create JSF 2.1, Primefaces 4.0, EJB, Restful Project, Using Maven, with JBoss AS 7, Postgres DB and Eclipse.

    primefaces

    In this step by step “tutorial”, I will try to demonstrate how to create a new JSF 2.1 Project and add Primefaces 4.0 to it, alongside with EJB, JPA, REST.

    I will use in this “tutorial”:

    used-toolkit

    and Ubuntu as OS.

    Contents:

    • Create Project Using Maven. (1)
    • Import and configure Eclipse Project. (2)
    • Add Primefaces.(3)

    Read more

  • Hibernate LazyInitializationException And p:selectCheckboxMenu

    primefaces

    I had a simple Entity with a @oneToMany relationship.

    Let’s call the Entity “Store” and the Entity of the relationship “Product”, obviously a Store has many Products.
    When it comes to use selectCheckboxMenu with the input (update) of products, a bug arise “org.hibernate.LazyInitializationException: could not initialize proxy – no Session”.
    For some reason using the primefaces selectCheckboxMenu (or h:selectmanycheckbox of the slandered JSF components) would end the Session of the current transaction.

    to solve this issue I had to supply the type of my collection to the component with attribute name=”collectionType”.

    it depends on your type of List if it’s a Set for example you can use java.util.HashSet instead of java.util.ArrayList.

  • JPA Criteria and JPQL

    JPA

    JPA2 introduced its “Criteria” queries, providing an API for typesafe query generation without the need to hardcode field names etc in queries; it built on the approach of Hibernate Criteria.
    In these examples we have two classes, Inventory and Product, where Inventory has a set of products.

    Select of persistable objects with simple filter

    JPQL single-string would be

    JPA Criteria would be

    JPQL single-string would be

    JPA Criteria would be

    Select of aggregate of attribute of persistable objects

    JPQL single-string would be
    Read more