hello everyone ,im new to this forum ,hope i will get answers for my problem :
i created entities from my Oracle database ,so as to retrieve data ...
Code:
import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
/**
* The persistent class for the BILAN database table.
*
*/
@Entity
@NamedQueries( {
@NamedQuery(name = "bilan.findAll", query = "from Bilan") })
public class Bilan implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private BilanPK id;
@Column(name="DATE_MAJ")
private BigDecimal dateMaj;
@Column(name="DATE_PURGE")
private BigDecimal datePurge;
private BigDecimal entete;
private String info;
public Bilan() {
}
public BilanPK getId() {
return this.id;
}
public void setId(BilanPK id) {
this.id = id;
}
public BigDecimal getDateMaj() {
return this.dateMaj;
}
public void setDateMaj(BigDecimal dateMaj) {
this.dateMaj = dateMaj;
}
public BigDecimal getDatePurge() {
return this.datePurge;
}
public void setDatePurge(BigDecimal datePurge) {
this.datePurge = datePurge;
}
public BigDecimal getEntete() {
return this.entete;
}
public void setEntete(BigDecimal entete) {
this.entete = entete;
}
public String getInfo() {
return this.info;
}
public void setInfo(String info) {
this.info = info;
}
}
Code:
import java.io.Serializable;
import javax.persistence.*;
/**
* The primary key class for the BILAN database table.
*
*/
@Embeddable
public class BilanPK implements Serializable {
//default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;
@Column(name="TYPE_BILAN")
private long typeBilan;
@Column(name="DATE_BILAN")
private long dateBilan;
@Column(name="TYPE_TABLE")
private long typeTable;
@Column(name="ID_EEC")
private long idEec;
public BilanPK() {
}
public long getTypeBilan() {
return this.typeBilan;
}
public void setTypeBilan(long typeBilan) {
this.typeBilan = typeBilan;
}
public long getDateBilan() {
return this.dateBilan;
}
public void setDateBilan(long dateBilan) {
this.dateBilan = dateBilan;
}
public long getTypeTable() {
return this.typeTable;
}
public void setTypeTable(long typeTable) {
this.typeTable = typeTable;
}
public long getIdEec() {
return this.idEec;
}
public void setIdEec(long idEec) {
this.idEec = idEec;
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof BilanPK)) {
return false;
}
BilanPK castOther = (BilanPK)other;
return
(this.typeBilan == castOther.typeBilan)
&& (this.dateBilan == castOther.dateBilan)
&& (this.typeTable == castOther.typeTable)
&& (this.idEec == castOther.idEec);
}
public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + ((int) (this.typeBilan ^ (this.typeBilan >>> 32)));
hash = hash * prime + ((int) (this.dateBilan ^ (this.dateBilan >>> 32)));
hash = hash * prime + ((int) (this.typeTable ^ (this.typeTable >>> 32)));
hash = hash * prime + ((int) (this.idEec ^ (this.idEec >>> 32)));
return hash;
}
}
the main class
Code:
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.log4j.Logger;
public class BilanService {
// private static final String PERSISTENCE_UNIT = "supe";
private static Logger logger = Logger.getLogger(BilanService.class);
public static void main(String[] args) {
// TODO Auto-generated method stub
logger.debug("** getBilan called...");
EntityManagerFactory entityManagerFactory = Persistence
.createEntityManagerFactory("testJPA");
EntityManager em = entityManagerFactory.createEntityManager();
Query findAllQuery = em.createNamedQuery("bilan.findAll");
List<Bilan> bilan = findAllQuery.getResultList();
Iterator stIterator=bilan.iterator();
while(stIterator.hasNext()){
Bilan st=(Bilan)stIterator.next();
System.out.print("id:"+st.getId());
System.out.print(" date maj:"+st.getDateMaj());
System.out.print(" date purge:"+st.getDatePurge());
System.out.println();
}
if (bilan != null)
logger.debug("** Found " + bilan.size() + " records:");
}
}
and the error !
Code:
log4j:WARN No appenders could be found for logger (sofrecom.adobe.services.BilanService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.SecurityException: class "javax.persistence.PersistenceContextType"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:39)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:34)
at sofrecom.adobe.services.BilanService.main(BilanService.java:35)
the jar that im using :
backport-util-concurrent.jar
cfgatewayadapter.jar
/commons-codec-1.3.jar
commons-httpclient-3.0.1.jar
commons-logging.jar
concurrent.jar
/ejb3-persistence.jar
/hibernate-annotations-3.4.0.GA.jar
/hibernate-cglib-repack-2.1_3.jar
hibernate-commons-annotations.jar
/hibernate-entitymanager-3.4.0.GA.jar
/hibernate-validator-3.1.0.GA.jar
/hibernate3.jar
/log4j-1.2.16.jar
/ojdbc6.jar
xalan.jar
hibernate-testing.jar
antlr-2.7.6.jar
\commons-collections-3.1.jar
\dom4j-1.6.1.jar
\jta-1.1.jar
\hibernate-jpa-2.0-api-1.0.0.Final.jar
\javassist-3.9.0.GA.jar
\cglib-2.2.jar
slf4j-api-1.6.1.jar
could someone help me plz !!