[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Unknown entity type

Hi,

I have an application with added derby.jar, added eclipselink.jar and javax.persistence.jar from eclipse eclipselink-2.0.0.v20090731-r4765 installtion zip.
I have entity class and some usage of this class and got different ind of message when try to use it like:
Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Error compiling the query [select object(o) from DiscountCode as o]. Unknown entity type [DiscountCode].
///
Caused by: Exception [EclipseLink-8034] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Error compiling the query [select object(o) from DiscountCode as o]. Unknown entity type [DiscountCode].
///


sometimes (may be with different version of eclipselink I have also message about missed "@Entity annotation"

What may be wrong?



////////////////////////

my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";>
<persistence-unit name="JavaApplication8PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>javaapplication8.DiscountCode</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/sample"/>
<property name="javax.persistence.jdbc.password" value="app"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.user" value="app"/>
</properties>
</persistence-unit>
</persistence>


my entity:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication8;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
*
* @author sp153251
*/
@Entity
@Table(name = "DISCOUNT_CODE")
@NamedQueries({@NamedQuery(name = "DiscountCode.findAll", query = "SELECT d FROM DiscountCode d"), @NamedQuery(name = "DiscountCode.findByDiscountCode", query = "SELECT d FROM DiscountCode d WHERE d.discountCode = :discountCode"), @NamedQuery(name = "DiscountCode.findByRate", query = "SELECT d FROM DiscountCode d WHERE d.rate = :rate")})
public class DiscountCode implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "DISCOUNT_CODE")
private Character discountCode;
@Column(name = "RATE")
private BigDecimal rate;


    public DiscountCode() {
    }

    public DiscountCode(Character discountCode) {
        this.discountCode = discountCode;
    }

    public Character getDiscountCode() {
        return discountCode;
    }

    public void setDiscountCode(Character discountCode) {
        this.discountCode = discountCode;
    }

    public BigDecimal getRate() {
        return rate;
    }

    public void setRate(BigDecimal rate) {
        this.rate = rate;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (discountCode != null ? discountCode.hashCode() : 0);
        return hash;
    }

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof DiscountCode)) {
return false;
}
DiscountCode other = (DiscountCode) object;
if ((this.discountCode == null && other.discountCode != null) || (this.discountCode != null && !this.discountCode.equals(other.discountCode))) {
return false;
}
return true;
}


@Override
public String toString() {
return "javaapplication8.DiscountCode[discountCode=" + discountCode + "]";
}


}