users@glassfish.java.net

Two simple entities but JPQL Query doesn't work

From: <glassfish_at_javadesktop.org>
Date: Fri, 03 Aug 2007 04:49:27 PDT

Hi!

I have two very [b]simple Entities[/b]
ShoppinCart and ShoppingCartPositions

 I'm trying to execute the query:
final Query q = em.createQuery([b]"SELECT count(x) FROM ShoppingCart x JOIN FETCH x.shoppingCardPositions"[/b]);

throws the Exception
used by: Exception [TOPLINK-8030] (Oracle TopLink Essentials - 2.0 (Build 35 (02/16/2007))): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Error compiling the query [SELECT count(x) FROM ShoppingCart x JOIN FETCH x.shoppingCardPositions], line 1, column 50:[b] unknown state or association field [shoppingCardPositions][/b] of class [de.epoq.dycide2.server.cart.ShoppingCart]


Any Ideas???
Thanks, stephan

Code:
@Entity
public class ShoppingCart
{

        private long id;
        private Date cdate;
        private List<ShoppingCartPostion> shoppingCardPositions;

        private String shoppingCartId;
        private String customerId;

        public ShoppingCart()
        {
        }

        @Temporal(TemporalType.TIMESTAMP)
        public Date getCdate()
        {
                return cdate;
        }

        public String getCustomerId()
        {
                return customerId;
        }

        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SHOPPING_CARD_GENERATOR")
        @SequenceGenerator(name = "SHOPPING_CARD_GENERATOR", sequenceName = "shoppingcard_id_seq")
        public long getId()
        {
                return id;
        }

        public String getShoppingCartId()
        {
                return shoppingCartId;
        }

        // /fetch = FetchType.EAGER)

        @OneToMany(cascade = CascadeType.ALL, mappedBy = "shoppingCart")
        public List<ShoppingCartPostion> getShoppingCartPositions()
        {
                return shoppingCardPositions;
        }

        public void setCdate(final Date newVal)
        {
                cdate = newVal;
        }

        public void setCustomerId(final String customerId)
        {
                this.customerId = customerId;
        }

        public void setId(final long id)
        {
                this.id = id;
        }

        public void setShoppingCardPositions(final List<ShoppingCartPostion> newVal)
        {
                shoppingCardPositions = newVal;
        }

        public void setShoppingCartId(final String shoppingCartId)
        {
                this.shoppingCartId = shoppingCartId;
        }

        public void setShoppingCartPositions(final List<ShoppingCartPostion> shoppingCartPositions)
        {
                this.shoppingCardPositions = shoppingCartPositions;
        }

}



-------------------------------------------------------------------------------------------------------------------------------------

@Entity
public class ShoppingCartPostion
{
        private long id;
        private String productcode;
        private int quantity;
        private double unitPrice;
        private Date cdate;
        private ShoppingCart shoppingCart; //backlink

        public ShoppingCartPostion()
        {
        }

        public ShoppingCartPostion(final String productcode, final int quantity, final double unitPrice, final ShoppingCart shoppingCart)
        {
                super();
                this.productcode = productcode;
                this.quantity = quantity;
                this.unitPrice = unitPrice;
                this.shoppingCart = shoppingCart;
                this.cdate = new Date(System.currentTimeMillis());
        }

        @Temporal(TemporalType.TIMESTAMP)
        public Date getCdate()
        {
                return cdate;
        }

        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SHOPPING_CARD_POSITION_GENERATOR")
        @SequenceGenerator(name = "SHOPPING_CARD_POSITION_GENERATOR", sequenceName = "shoppingcard_position_id_seq")
        public long getId()
        {
                return id;
        }

        public String getProductcode()
        {
                return productcode;
        }

        public int getQuantity()
        {
                return quantity;
        }

        @ManyToOne
        public ShoppingCart getShoppingCart()
        {
                return shoppingCart;
        }

        public double getUnitPrice()
        {
                return unitPrice;
        }

        public void setCdate(final Date cdate)
        {
                this.cdate = cdate;
        }

        public void setId(final long id)
        {
                this.id = id;
        }

        public void setProductcode(final String newVal)
        {
                productcode = newVal;
        }

        public void setQuantity(final int newVal)
        {
                quantity = newVal;
        }

        public void setShoppingCart(final ShoppingCart shoppingCart)
        {
                this.shoppingCart = shoppingCart;
        }

        public void setUnitPrice(final double newVal)
        {
                unitPrice = newVal;
        }

}
[Message sent by forum member 'iceandfire' (iceandfire)]

http://forums.java.net/jive/thread.jspa?messageID=229329