0

i am new in jee i create two entities with different namedquery. when i run my application on wildfly 10, only one entity generated in the data base despite when i check my console i find my two entities in jndi. this is my two classes: models:

@Entity
@NamedQuery(name="ClientBanque.findAll", query="SELECT client FROM ClientBanque client")
public class ClientBanque implements Serializable {
    @Id
    int cin;
    String prenom;
    String nom;
    String adress;
    //getters and setters
    // constructor using fields

}

@NamedQuery(name="CompteBancair.findAll", query="SELECT c FROM CompteBancair c")
public class CompteBancair implements Serializable {

    @Id
    long rib;
    float solde;

// getters, setters, constructor

}

dao:

@Stateless
public class ClientBanqueDAO {

    @PersistenceContext
    private EntityManager em;

    public void persist(ClientBanque client) {
        em.persist(client);
    }

    public List<ClientBanque> getAllCustomers() {


        Query q =  em.createNamedQuery("ClientBanque.findAll", ClientBanque.class);
        List<ClientBanque> resultList = q.getResultList();
        return resultList;
    }
}


@Stateless
public class CompteBancaireDAO {
    @PersistenceContext
    private EntityManager em;

    public void persistAcount(CompteBancair compte) {
        em.persist(compte);
    }

    public List<CompteBancair> getAllAcount() {
        Query q =  em.createNamedQuery("CompteBancair.findAll", CompteBancair.class);
        List<CompteBancair> resultList = q.getResultList();
        return resultList;
    }

}

the persistant.xml contains :

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
   version="1.0">
   <persistence-unit name="bank">
      <jta-data-source>java:jboss/mysql/bank</jta-data-source>
      <properties>
          <property name="hibernate.hbm2ddl.auto" value="update"/>
      </properties>
   </persistence-unit>
</persistence>

what i can do to fix this problem ?

MeBigFatGuy
  • 28,272
  • 7
  • 61
  • 66
Hamdy
  • 430
  • 1
  • 6
  • 19
  • I recreate the project with the same code. it works. what happens? i don't know ! – Hamdy Dec 11 '16 at 23:02
  • 4
    I'm not sure I fully understand the question, but if the snippets above are accurate the `CompteBancair` is missing the `@Entity` annotation. – James R. Perkins Dec 13 '16 at 18:08

0 Answers0