1 Reply Latest reply: Oct 23, 2010 3:53 AM by YoungWinston RSS

    EJB

    807636
      Hi there,

      I have two java files IdAssign.java and MappedConnection.java.

      In IdAssign.java I have the following code:

      @Entity
      @Table(name = "IDASSIGN")
      @NamedQueries({
      @NamedQuery(name = "IdAssign.findAll", query = "SELECT i FROM IdAssign i"),
      @NamedQuery(name = "IdAssign.findByIdassign", query = "SELECT i FROM IdAssign i WHERE i.idassign = :idassign"),
      @NamedQuery(name = "IdAssign.findById", query = "SELECT i FROM IdAssign i WHERE i.id = :id")})
      public class IdAssign implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Basic(optional = false)
      @Column(name = "IDASSIGN")
      private BigDecimal idassign;
      @Basic(optional = false)
      @Column(name = "ID")
      private short id;

      public IdAssign() {
      }
      @Override
      public String toString() {
      return "com.entity.jpa.util.IdAssign[idassign=" + idassign + "]";
      }
      }

      In MappedConnection I have the folowing code:

      @Local
      public class MappedConnection implements MappedConnectionLocal{

      @PersistenceContext
      private EntityManager em;

      // private IdAssign idAssign;

      // Add business logic below. (Right-click in editor and choose
      // "Insert Code > Add Business Method")
      public MappedConnection() {
      }

      public void doBean() {


      Query q = em.createNamedQuery("IdAssign.findAll");
      q.setMaxResults(1);

      IdAssign objA = (IdAssign) q.getSingleResult();
      objA.getId();
      }

      The problem is that in em.createNamedQuery does not recognise "IdAssign.findAll".

      Could someone give me some advice.
        • 1. Re: EJB
          YoungWinston
          804633 wrote:
          The problem is that in em.createNamedQuery does not recognise "IdAssign.findAll".
          Could someone give me some advice.
          Yes
          1. Post your code inside '
          ' or '[code ]...[/code ]' tags (without the spaces).
          2. Provide the exact message you're getting. In fact, the first few lines of the stack trace would probably be best.
          
          Winston