Hi, ich hab ein kleines Problem und zwar, wenn ich ein Objekt in der Datenbank(MySQL) speichern will,wird ständig so ein Exception rausgeworfen : java.lang.IllegalArgumentException: Object: jpa.model.entities.cars[ id=null ] is not a known entity type.
[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="WebJPAPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>bazaDatebase</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
[/XML]
Wie gesagt es wird ständig diese Exception angezeigt:
java.lang.IllegalArgumentException: Object: jpa.model.entities.cars[ id=null ] is not a known entity type.
Kann mir bitte jemand sagen, wie man dieses Problem beheben kann.
Vielen Dank im Voraus!!!!!
Java:
@Entity
public class Cars implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String password;
// ... getters and setters
Java:
@ViewScoped
@ManagedBean(name="login")
public class Login implements Serializable {
private String name;
private String password;
private EntityManagerFactory controll;
public void checkLogin(){
controll = Persistence.createEntityManagerFactory("WebJPAPU");
EntityManager em = controll.createEntityManager();
em.getTransaction().begin();
Cars todo = new Cars();
todo.setName(name);
todo.setPassword(password);
em.persist(todo);
em.getTransaction().commit();
em.close();
}
//getters and setters
[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="WebJPAPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>bazaDatebase</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
[/XML]
Wie gesagt es wird ständig diese Exception angezeigt:
java.lang.IllegalArgumentException: Object: jpa.model.entities.cars[ id=null ] is not a known entity type.
Kann mir bitte jemand sagen, wie man dieses Problem beheben kann.
Vielen Dank im Voraus!!!!!