Hibernate not generating foreign keys in database - java

I created a many to one relationship between my tables Person and adress it appears to be created given my ER diagram. But it's not making anything happen in my datasource, no join no
Is there a way to make this happen or is it supposed to be like that for Intellij? Seems to be easy to do with Eclipse.
This is my code for both entities and anything I think is relevant, don't hesitate to ask if you need anything.
#Entity
#Table(name = "personne", schema = "bddpersistence")
#IdClass(PersonneEntityPK.class)
public class PersonneEntity {
private int idPersonne;
private String nom;
private String prenom;
private String email;
private String tel;
private Integer age;
private Integer idAdress;
#OneToMany(mappedBy = "personne",cascade = CascadeType.ALL,orphanRemoval = true)
private List<AdressEntity> adress = new ArrayList<AdressEntity>();
#Entity
#Table(name = "adress", schema = "bddpersistence")
public class AdressEntity {
private String rue;
private Integer codePostal;
private String ville;
private int idAdress;
#ManyToOne
PersonneEntity personne;
package com.example;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import javax.persistence.*;
import java.sql.Timestamp;
public class TestHibernate {
static EntityManagerFactory emf;
static EntityManager em;
static EntityTransaction transaction;
public static void beginConnection(){
emf = Persistence.createEntityManagerFactory("NewPersistenceUnit");
em = emf.createEntityManager();
transaction = em.getTransaction();
transaction.begin();
}
public static void endConnection(){
transaction.commit();
em.close();
emf.close();
}
public static void insertAccount(String email, String name){
ComptesEntity compte = new ComptesEntity();
compte.setEmail(email);
compte.setNom(name);
em.persist(compte);
}
public static void createPerson (int id_personne,String nom,String prenom,int age,String email,String tel,String rue,String cp,String ville){
}
public static void insertPerson(String lastName, String firstName , String email, String tel , int age){
PersonneEntity personne = new PersonneEntity();
personne.setNom(lastName);
personne.setPrenom(firstName);
personne.setTel(tel);
personne.setEmail(email);
personne.setAge(age);
em.persist(personne);
}
public static void main(String[] args) {
beginConnection();
endConnection();
}
}
Here is the persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="NewPersistenceUnit">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/bddpersistence"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="kamoulox369"/>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
And here is the hibernate config :
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/bddpersistence</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
<mapping class="com.example.AdressEntity"/>
<mapping resource="com/example/AdressEntity.hbm.xml"/>
<mapping class="com.example.ClubEntity"/>
<mapping resource="com/example/ClubEntity.hbm.xml"/>
<mapping class="com.example.ComptesEntity"/>
<mapping resource="com/example/ComptesEntity.hbm.xml"/>
<mapping class="com.example.ParticipationEntity"/>
<mapping resource="com/example/ParticipationEntity.hbm.xml"/>
<mapping class="com.example.PersonneEntity"/>
<mapping resource="com/example/PersonneEntity.hbm.xml"/>
<!-- <property name="connection.username"/> -->
<!-- <property name="connection.password"/> -->
<!-- DB schema will be updated if needed -->
<!-- <property name="hbm2ddl.auto">update</property> -->
</session-factory>
</hibernate-configuration>
Lastly the composite PK for PersonEntity :
package com.example;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Objects;
public class PersonneEntityPK implements Serializable {
private int idPersonne;
private String email;
#Column(name = "id_personne")
#Id
public int getIdPersonne() {
return idPersonne;
}
public void setIdPersonne(int idPersonne) {
this.idPersonne = idPersonne;
}
#Column(name = "email")
#Id
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
#Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PersonneEntityPK that = (PersonneEntityPK) o;
return idPersonne == that.idPersonne &&
Objects.equals(email, that.email);
}
#Override
public int hashCode() {
return Objects.hash(idPersonne, email);
}
}
I left out part of the code for entity that was just generated like the getters and setters.

Related

Why hibernate doesn't create tables automatically even with hibernate.hbm2ddl.auto" value="create"?

I'm trying to force hibernate to create a student table if it doesn't exist, but without success, Hibernate library should be able to do that, but I'm getting an error saying there is no such table in the database, not sure what is the problem :
Details:
Student class
import javax.persistence.Entity;
import javax.persistence.Id;
#Entity
public class Student {
#Id
int id;
int phoneNumber;
public Student() {
}
public Student(int id, int phoneNumber) {
this.id = id;
this.phoneNumber = phoneNumber;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(int phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
Main class
public class Main {
public static void main(String[] args) {
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("ss");
EntityManager entityManager = entityManagerFactory.createEntityManager();
Student student = new Student(5,55);
entityManager.getTransaction().begin();
entityManager.persist(student);
entityManager.getTransaction().commit();
}
}
Persistance.xml file
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ss" transaction-type="RESOURCE_LOCAL">
<class>com.youssef.Student</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/sotamag" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
Note:
-I've added the following property <property name="hibernate.hbm2ddl.auto" value="create"/> to force hibernate to create the table, but still, I get the error saying there is no such table in the database.
-i'm using MySQL as database
`
If you are using MySQL5 or above, you can try changing your Dialect to:
<property name="hibernate.dialect">org.hibernate.dialect.MySQL55Dialect</property>

Hibernate JAVA | How to get an instance of EntityManager WITHOUT creating a new table?

every time that I want to get the instance of Entity Manager is creating new tables in the database, so how I can get the EntityManager (to insert, delete, update the database) in Postgresql without creating new tables?
Entity "Medico":
#Entity
#Table(name = "medico")
#SequenceGenerator (name = "medico_seq",sequenceName="medico_seq",allocationSize = 1, initialValue = 1)
public class Medico implements Serializable{
#Id
#GeneratedValue(strategy=GenerationType.SEQUENCE,generator = "medico_seq")
private Integer id = null;
private String especializacao;
private Integer diasRetorno;
private Time tempoConsulta;
private String nome;
private String cpf;
private String email;
private String senha;
private String telefone;
private String cidade;
private String estado;
private String cep;
private String endereco;
private String bairro;
private Integer enderecoNumero;
public Medico(String especializacao, Integer diasRetorno, Time tempoConsulta, String nome, String cpf, String email, String senha, String telefone, String cidade, String estado, String cep, String endereco, String bairro, Integer enderecoNumero) {
//...
}
//getters and setters
}
"MedicoDAO"
package dao;
import entidade.Medico;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.hibernate.Session;
public class MedicoDAO {
public Medico salvar (Medico medico){
EntityManager em = Persistence.createEntityManagerFactory("PersistenciaPU").createEntityManager();
try{em.getTransaction().begin();
if(medico.getId()==null){
em.persist(medico); //Faz o insert
}
else{
medico = em.merge(medico); // Faz o update
}
em.getTransaction().commit();
}catch(Exception ex){
System.err.println("ERRO123: "+ex.getMessage());
}finally{
em.close();
}
em.close();
return medico;
}
}
"Persistence.xml"
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="PersistenciaPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>entidade.HorarioAtendimentoMedico</class>
<class>entidade.Medico</class>
<class>entidade.Paciente</class>
<properties>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/clinica"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.password" value="123456"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
main:
package persistencia;
import dao.Auxiliar;
import dao.MedicoDAO;
import entidade.Medico;
import java.sql.Time;
import javax.persistence.Persistence;
public class Persistencia {
public static void main(String[] args) {
Time t = new Time(2,3,4);
Medico medico = new Medico("Cirurgiao",7,t,"Roberto","555.458.912-12","roberto#medico.com","12345","48 3275 0463", "Florianópolis", "SC", "88.222-200","Rua Bonita","Lagoa",12);
MedicoDAO dao = new MedicoDAO();
dao.salvar(medico);
}
}
Error:
Exception in thread "main" javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table medico]
Caused by: org.postgresql.util.PSQLException: ERROR: relation "medico" already exists
I can't see the Image. but try to change
<property name="hibernate.hbm2ddl.auto">create</property> // create new schema
to this:
<property name="hibernate.hbm2ddl.auto">update</property> // update the schema
I got!
What was needed is delete this line of the persistence.xml:
property name="javax.persistence.schema-generation.database.action" value="create"/
Thanks for help me to notice this line

org.hibernate.MappingException: Unknown entity

This question is different from the other questions on the same topic of MappingException: Unknown entity because I have this line in my hibernate config:
<mapping class="bbb.Students" />
My entity class is as follows:
package bbb;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "Students")
public class Students implements java.io.Serializable {
private String id;
private String name;
private String number;
#Id
#Column(name = "ID", unique = true, nullable = false)
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
#Column(name = "NAME", nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Column(name = "NUMBER", nullable = false)
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
}
I have the database test and the table Students manually created.
The error is:
org.hibernate.MappingException: Unknown entity: bbb.Students
Exception in thread "main" org.hibernate.MappingException: Unknown entity: bbb.Students
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:776)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1533)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:682)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:674)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:669)
at bbb.App.main(App.java:39)
The Main class is as follows:
package bbb;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
public class App
{
public static void main( String[] args )
{
System.out.println("Hibernate one to one (Annotation)");
Configuration conf = new Configuration();
SessionFactory sf = conf.configure()
.buildSessionFactory(
new StandardServiceRegistryBuilder()
.applySettings(conf.getProperties())
.build());
Session session = sf.openSession();
session.beginTransaction();
Students s = new Students();
s.setId("1");
s.setName("Joe");
s.setNumber("12345");
session.save(s);
session.getTransaction().commit();
System.out.println("Done");
}
}
The full hibernate.config is as follows:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<mapping class="bbb.Students" />
</session-factory>
</hibernate-configuration>
Just imported your Students class in a Hibernate based project. Everything work fine. Before running the application, I created schema "test" manually. Post a class with the main method. Probably something is wrong in it.
Update:
Imported your's main method. The application still works. Can't reproduce an issue.
import bbb.Students;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
public class Main {
private static final SessionFactory ourSessionFactory;
static {
try {
ourSessionFactory = new Configuration().
configure("hibernate.cfg.xml").
buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public static void main(final String[] args) throws Exception {
final Session session = getSession();
try {
Transaction transaction= session.beginTransaction();
Students student = new Students();
student.setName("Vasua");
student.setNumber("13");
student.setId("1");
session.save(student);
transaction.commit();
} finally {
session.close();
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernte Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">
jdbc:mysql://localhost/stack
</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.username">
root
</property>
<property name="connection.password">
root
</property>
<!-- DB schema will be updated if needed -->
<property name="hbm2ddl.auto">update</property>
<mapping class="bbb.Students"/>
</session-factory>
</hibernate-configuration>

Hibernate + PostgreSQL throws an Exception: Unknown entity

I write a java maven project for restful webservice using jersey + hibernate and having below error:
javax.servlet.ServletException: org.hibernate.MappingException:
Unknown entity: org.asad.dto.logindetail
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:419)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
381)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:
221)
hibernate.cfg.xml File:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Drive</property>
<property
name="connection.url">jdbc:postgresql://localhost:5432/logindb</property>
<property name="connection.username">postgres</property>
<property name="connection.password">project</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property
name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<propertyname="connection.driver_class">org.postgresql.Driver</property>
<!-- Names the annotated entity class -->
<mapping class="org.asad.dto.logindetail"/>
</session-factory>
</hibernate-configuration>
The table name is "logindetail".
Database Class:
#Entity
#Table (name = "logidetail") public class logindetail {
#Id
int userId;
String name;
String password;
public void setUserId(int i){
this.userId = i;
}
public int getUserId(){
return userId;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setPassword(String pass){
this.password = pass;
}
public String getPassword(){
return password;
}}
Main Class:
package org.asad.login.login.loginservice;
import java.util.ArrayList;
import javax.management.Query;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.asad.dto.logindetail;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configurationimport org.hibernate.classic.Session;
public class LoginService{
SessionFactory sessionFactory = null;
Session session = null;
public String getDatabaseUser(){
logindetail user = null;
String name=null;try{
sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
session.beginTransaction();
user = (logindetail)session.get(logindetail.class, 2);
name = user.getName();
session.getTransaction().commit();
session.close();
}catch(Exception e){
e.printStackTrace();
}
return name;
}}
now this error is coming java.lang.NullPointerException
anyone can help me to eliminate this error i will b thankful :)
Can you check if you imported correct #Entity annotation.
As #Entity comes under two packages one is org.hibernate.annotations.Entity and other one with javax.persistence.Entity.
Use javax.persistence.Entity to annotate your entity beans. Don't import org.hibernate.annotations.Entity.

class listed in the persistence.xml file but not mapped

I have listed my class in persistence.xml but mapped class is not recognized inside.
I tried <exclude-unlisted-classes>false</exclude-unlisted-classes>
But no luck.
My persistence.xml file
<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_2_0.xsd"
version="2.0">
<persistence-unit name="advertiserAPI" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.advertiser.model.Application</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://host:port/DB" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.autoReconnect" value="true"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.validator.apply_to_ddl" value="false"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.use_sql_comments" value="true"/>
<property name="hibernate.default_batch_fetch_size" value="16"/>
<property name="hibernate.current_session_context_class" value="thread"/>
</properties>
</persistence-unit>
</persistence>
Test class file
package com.advertiser.model.test;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.servlet.ServletException;
import org.junit.Test;
import com.advertiser.model.Application;
public class ApplicationTest {
#Test
public void listAll() throws ServletException {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("advertiserAPI");
try {
EntityManager em = emf.createEntityManager();
Query query = em.createQuery("SELECT id FROM Application");
System.out.println("query " + query);
} catch (Exception ex) {
ex.printStacktrace();
}
}
}
Application class has following
package com.advertiser.model;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Entity;
import static org.apache.commons.lang.builder.ToStringStyle.MULTI_LINE_STYLE;
#Entity
#Table(name = "applications")
public class Application {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "id", unique = true, nullable = false, insertable = false, updatable = false)
private Integer id;
#Column(name = "name", length = 255)
private String name;
#Column(name = "host", length = 255, nullable = false)
private String host;
#Column(name = "app_type", columnDefinition = "TINYINT")
private String appType;
#ManyToOne
#JoinColumn(name = "advertiser_id")
private Integer advertiserId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getAppType() {
return appType;
}
public void setAppType(String appType) {
this.appType = appType;
}
public Integer getAdvertiserId() {
return advertiserId;
}
public void setAdvertiserId(Integer advertiserId) {
this.advertiserId = advertiserId;
}
}
You have annotated your class with #org.hibernate.annotations.Entity instead of annotating it with #javax.persistence.Entity.

Categories

Resources