here my entities classes linked by ManyToMany:
Product :
package fr.test;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
#Entity
#Table(name = "product")
public class ProductDTO {
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE)
#Column(name = "product_id")
private int id;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
#Column(name = "nom_product")
private String nom;
public String getNom() {return nom;}
public void setNom(String nom) {this.nom = nom;}
#Column(name = "application")
private String application;
public String getGroupeApplication() {return groupeApplication;}
public void setGroupeApplication(String groupeApplication) {this.groupeApplication = groupeApplication;}
#Column(name = "grp_app")
private String groupeApplication;
public String getApplication() {return application;}
public void setApplication(String application) {this.application = application;}
#ManyToMany
#JoinTable(name = "product_mot_cle")
private List<MotCleDTO> motscleInterdits;
public List<MotCleDTO> getMotscleInterdits() {return motscleInterdits;}
public void setMotscleInterdits(List<MotCleDTO> motscleInterdits) {this.motscleInterdits = motscleInterdits;}
#ManyToMany
#JoinTable(name ="product_extension")
private List<ExtensionDTO> extensionsDisponibles;
public List<ExtensionDTO> getExtensionsDisponibles() {return extensionsDisponibles;}
public void setExtensionsDisponibles(List<ExtensionDTO> extensionsDisponibles) {this.extensionsDisponibles = extensionsDisponibles;}
#OneToMany(mappedBy="prodDiff")
List<DiffusionDTO> destinatairesPrincipaux;
public List<DiffusionDTO> getDestinatairesPrincipaux() {return destinatairesPrincipaux;}
public void setDestinatairesPrincipaux(List<DiffusionDTO> destinatairesPrincipaux) {this.destinatairesPrincipaux = destinatairesPrincipaux;}
#OneToMany(mappedBy="product")
private List<LivraisonDTO> prodLivr;
public List<LivraisonDTO> getProdLivr() {return prodLivr;}
public void setProdLivr(List<LivraisonDTO> prodLivr) {this.prodLivr = prodLivr;}
#ManyToMany(mappedBy="prodList")
private List<EnvironnementDTO> envList;
public List<EnvironnementDTO> getEnvList() {return envList;}
public void setEnvList(List<EnvironnementDTO> envList) {this.envList = envList;}
public ProductDTO() {
}
public ProductDTO(int id, String nom, String appli, String grpAppli) {
this.id = id;
this.nom = nom;
this.application = appli;
this.groupeApplication = grpAppli;
}
}
and Environnment :
#Entity
#Table(name="environnement")
public class EnvironnementDTO {
#Id
#GeneratedValue(strategy=GenerationType.SEQUENCE)
#Column(name="environnement_id")
private int id;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
#Column(name="machine_alias")
private String machineAlias;
public String getMachineAlias() {return machineAlias;}
public void setMachineAlias(String machineAlias) {this.machineAlias = machineAlias;}
#Column(name="instance")
private String instance;
public String getInstance() {return instance;}
public void setInstance(String instance) {this.instance = instance;}
#Column(name="port")
private String port;
public String getPort() {return port;}
public void setPort(String port) {this.port = port;}
#OneToMany(mappedBy="environnement")
private List<LivraisonDTO> livrEnv;
public List<LivraisonDTO> getLivrEnv() {return livrEnv;}
public void setLivrEnv(List<LivraisonDTO> livrEnv) {this.livrEnv = livrEnv;}
#ManyToMany
#JoinTable(name="lien_product_environnement",
joinColumns=#JoinColumn(name="environnement_id", referencedColumnName="environnement_id"),
inverseJoinColumns=#JoinColumn(name="product_id",referencedColumnName="product_id"))
private List<ProductDTO> prodList;
public List<ProductDTO> getProdList() {return prodList;}
public void setProdList(List<ProductDTO> prodList) {this.prodList = prodList;}
public EnvironnementDTO() {
}
public EnvironnementDTO(int id, String machineAlias, String instance, String port) {
this.id = id;
this.machineAlias = machineAlias;
this.instance = instance;
this.port = port;
}
}
here my JPQL query :
SELECT env FROM EnvironnementDTO env JOIN ProductDTO p WHERE p.id=2
The generated query on postgres is the following :
select environnem0_.environnement_id as environn1_3_, environnem0_.instance as instance2_3_, environnem0_.machine_alias as machine_3_3_, environnem0_.port as port4_3_ from environnement environnem0_ inner join product productdto1_ on where productdto1_.product_id=2
as you can see : the sql executed on postgres dot not follow the mapping table for many to many designated in #JoinTable on EnvironnementDTO..
We double-checked our annotations, seems jpa or hibernate does not use them to generate the good query !
I'm aware it's certainly a mistake on my side... but don't understand what's happening.
You have to mention the association on which you want to join in the query
SELECT env FROM EnvironnementDTO env JOIN env.prodList p WHERE p.id=2
Related
I have the following classes
import java.util.Set;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
#NodeEntity
public class Client {
#Id
#GeneratedValue
private Long id;
private String name;
#Relationship(type = "HAS_CONFIGURED", direction = Relationship.OUTGOING)
public Set<Environment> environments;
public Client () {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Environment> getEnvironments() {
return environments;
}
public void setEnvironments(Set<Environment> environments) {
this.environments = environments;
}
}
import java.util.Set;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
#NodeEntity
public class Environment {
#Id
#GeneratedValue
private Long id;
private String name;
#Relationship(type = "HAS_INSTALLED", direction = Relationship.OUTGOING)
public Set<Application> applications;
public Environment() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Application> getApplications() {
return applications;
}
public void setApplications(Set<Application> applications) {
this.applications = applications;
}
}
import java.util.Set;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
import org.neo4j.ogm.annotation.RelationshipEntity;
#NodeEntity
public class Application {
#Id
#GeneratedValue
private Long id;
private String name;
#Relationship(type = "CAN_THROW", direction = Relationship.OUTGOING)
public Set<Error> errors;
public Application() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Error> getErrors() {
return errors;
}
public void setErrors(Set<Error> errors) {
this.errors = errors;
}
}
And I am trying to load them all using a crud repository
import java.util.List;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import com.nic.loganalyzer.loganalyzer.model.entity.graph.Client;
public interface ClientRepository extends Neo4jRepository<Client, Long> {
List<Client> findAllByName(String name);
}
Hierarchy is like Client-->Environment-->Application--Error.
The problem is that it loads only till Applications but Application does not load environments.
Is it loaded eagerly?
Or else how can I load the entire structure and traverse.
The way I traverse is as follows
List<Client> findAllByName = clientRepository.findAllByName(eventLog.getClient());
for (Client client: findAllByName) {
List<Environment> environments = client.getEnvironments().stream()
.filter(e -> e.getName().equalsIgnoreCase(eventLog.getEnvironment()))
.collect(Collectors.toList());
for (Environment environment : environments) {
List<Application> applications = environment.getApplications().stream()
.filter(e -> e.getName().equalsIgnoreCase(eventLog.getApplication()))
.collect(Collectors.toList());
for (Application application : applications) {
List<Error> errors = application.getErrors().stream()
.filter(e -> eventLog.getError().contains(e.getName()))
.collect(Collectors.toList());
As far as I understand, the default "depth" value on derived finders is 1.
If you want to load the whole hierarchy, try adding #Depth(value = 3) on top of your derived finder.
Your method should look like:
#Depth(value = 3)
List<Client> findAllByName(String name);
Requirement is to get the records from database where particular columns and the table name is selected at run time.
I am using Java, Hibernate and Mysql. It is possible using JDBC. but i want to do it using hibernate.
Post the hints, if anybody knows
Thanks in advance
Well, Hibernate can do much more than just JDBC, what you're looking for can be written like this with Hibernate:
Query query = session.createSQLQuery(
"select s.stock_code from stock s where s.stock_code = :stockCode")
.setParameter("stockCode", "7277");
List result = query.list();
As you can see the table name and columns can be defined on the fly, this is at least on par with JDBC, and probably even simpler. You don't have to use parameters, you can modularly build your query in the code, obviously.
Reference for more details
https://www.mkyong.com/hibernate/hibernate-native-sql-queries-examples/
Hibernate has more features than JDBC. The best feauture is Hibernate support Object Oriented Principles. You can use Polymorphism, Inheritance, Encapsulation for your entities.
You must have a BaseEntity class and all other classes must extends from this class.
public class BaseEntity {
}
Then all other classes extends this class. Assume that, you have two other classes or entities.
User.class
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Table(name = "USERS")
#Entity
public class User extends BaseEntity implements Serializable {
#Id
#Column(name = "ID")
private int id;
#Column(name = "NAME")
private String name;
#Column(name = "SURNAME")
private String surname;
public User() {
}
public User(int id, String name, String surname) {
this.id = id;
this.name = name;
this.surname = surname;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
Info.class
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Table(name = "INFO")
#Entity
public class Info extends BaseEntity implements Serializable {
#Column(name = "TEXT")
private String text;
#Id
#Column(name = "ID")
private int id;
public Info() {
}
public Info(String text, int id) {
this.text = text;
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Also you must add mapping tag for each class to configuration.hbm.xml
Your DAO is look like following.
public List getList(BaseEntity baseEntity, String[] columnNames) {
Criteria criteria = session.createCriteria(baseEntity.getClass(), "be");
ProjectionList projectionList = Projections.projectionList();
for (String columnName : columnNames) {
projectionList.add(Projections.property("be." + columnName), columnName); // adding column for selection
}
criteria.setProjection(projectionList);
criteria.setResultTransformer(new AliasToBeanResultTransformer(baseEntity.getClass())); // for mapping result to entity
return criteria.list();
}
public static void main(String[] args) {
String[] columnNames = {"name", "surname"}; // columnNames which you want to select
List<Info> users = new GeneralDAO().getList(new User(), columnNames); // you can pass any class User, Info or etc.
}
I'm using the JPA EntityManager.getReference(Class clazz, Integer pk).
I know that pk value is set to one but still, in the object returned by the method, the value is set to zero. I don't understand why.
Here's my code:
#Component
public class TypeDAO extends MainDAO {
public TypeDTO simpleProxyRetrieveByIdType(int id){
TypeDTO type = simpleProxyRetrieveById(TypeDTO.class, id);
return type;
}
}
My MainDAO class:
static protected <E> E simpleProxyRetrieveById(Class <E> clazz, Integer id) {
EntityManager em = emFactory.createEntityManager();
E item = em.getReference(clazz, id);
em.close();
return item;
}
Here is the TypeDTO class:
#Entity
#Table(name = "type_livr")
public class TypeDTO {
#Id
#GeneratedValue(strategy = GenerationType.SEQUENCE)
#Column(name = "type_livraison_id")
private int id;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
#Column(name = "code")
private int code;
public int getCode() {return code;}
public void setCode(int code) {this.code = code;}
#Column(name = "libelle_court")
private String libelleCourt;
public String getLibelleCourt() {return libelleCourt;}
public void setLibelleCourt(String libelleCourt) {this.libelleCourt = libelleCourt;}
#Column(name = "libelle_long")
private String libelleLong;
public String getLibelleLong() {return libelleLong;}
public void setLibelleLong(String libelleLong) {this.libelleLong = libelleLong;}
#OneToMany(mappedBy = "type")
private List<LivraisonDTO> typeLivr;
public List<LivraisonDTO> getTypeLivr() {return typeLivr;}
public void setTypeLivr(List<LivraisonDTO> typeLivr) {this.typeLivr = typeLivr;}
public TypeDTO() {
}
public TypeDTO(int id, int code, String libelleCourt, String libelleLong) {
this.id = id;
this.code = code;
this.libelleCourt = libelleCourt;
this.libelleLong = libelleLong;
}
}
Thanks for any answer.
There is no problem in fact :
id is not really initialized to real id until you called the getId() getter.
You should have checked only in debugger !
I am new to hibernate.
My problem is to resolve multiple Foreign Keys to their Value. I am able to do it with SQL but the Hibernate Annotations makes me crazy.
I got these 2 Tables for example:
Table MoveSets
MoveSet_ID
Punch_1
Punch_2
Graple_1
Graple_2
Graple_3
Graple_4
Table Moves
Move_ID
Name
Damage
MoveType_ID
Counterchance
The Punches and Graples are all foreign keys referencing to Move_ID.
My target is to do a session.createQuery("from MoveSets").list(); and to get a Moveset with the Names of the Moves instead of the IDs.
Is this possible in Hibernate?
package hibernate;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
#Entity
#Table(name = "Moves")
public class Moves implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1522367877613954187L;
private int id;
private String name;
private int damage;
private int movetype_id;
private int counterchance;
public Moves() {
}
public Moves(int id, String name, int damage, int movetype_id,
int counterchance) {
this.id = id;
this.name = name;
this.damage = damage;
this.movetype_id = movetype_id;
this.counterchance = counterchance;
}
#Id
#Column(name = "Move_ID")
#GeneratedValue(generator = "increment")
#GenericGenerator(name = "increment", strategy = "increment")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
#Column(name = "Name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Column(name = "Damage")
public int getDamage() {
return damage;
}
public void setDamage(int damage) {
this.damage = damage;
}
#Column(name = "MoveType_ID")
public int getMovetype_id() {
return movetype_id;
}
public void setMovetype_id(int movetype_id) {
this.movetype_id = movetype_id;
}
#Column(name = "Counterchance")
public int getCounterchance() {
return counterchance;
}
public void setCounterchance(int counterchance) {
this.counterchance = counterchance;
}
#Override
public String toString() {
return "Moves - Name: " + name;
}
}
And
package hibernate;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
#Entity
#Table(name = "MoveSets")
public class MoveSets implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6488498413048804953L;
private int id;
private int punch_1;
private int punch_2;
private int graple_1;
private int graple_2;
private int graple_3;
private int graple_4;
public MoveSets() {
}
public MoveSets(int id, int punch_1, int punch_2, int graple_1,
int graple_2, int graple_3, int graple_4) {
this.id = id;
this.punch_1 = punch_1;
this.punch_2 = punch_2;
this.graple_1 = graple_1;
this.graple_2 = graple_2;
this.graple_3 = graple_3;
this.graple_4 = graple_4;
}
#ManyToOne
#JoinColumn(name = "Moves_ID")
public Moves moves;
#Id
#Column(name = "MoveSet_ID")
#GeneratedValue(generator = "increment")
#GenericGenerator(name = "increment", strategy = "increment")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
#Column(name = "Punch_1")
public int getPunch_1() {
return punch_1;
}
public void setPunch_1(int punch_1) {
this.punch_1 = punch_1;
}
#Column(name = "Punch_2")
public int getPunch_2() {
return punch_2;
}
public void setPunch_2(int punch_2) {
this.punch_2 = punch_2;
}
#Column(name = "Graple_1")
public int getGraple_1() {
return graple_1;
}
public void setGraple_1(int graple_1) {
this.graple_1 = graple_1;
}
#Column(name = "Graple_2")
public int getGraple_2() {
return graple_2;
}
public void setGraple_2(int graple_2) {
this.graple_2 = graple_2;
}
#Column(name = "Graple_3")
public int getGraple_3() {
return graple_3;
}
public void setGraple_3(int graple_3) {
this.graple_3 = graple_3;
}
#Column(name = "Graple_4")
public int getGraple_4() {
return graple_4;
}
public void setGraple_4(int graple_4) {
this.graple_4 = graple_4;
}
#Override
public String toString() {
return "MoveSet - ID: " + id + " Punch 1: " + punch_1;
}
}
Yes it is possible, in fact the whole point of ORM and Hibernate is to get objects (your values) insteed of plain IDs. Your mapping is wrong. You should map your relations (I assume that punches and grapples are moves) via annotations like #OneToOne,#OneToMany and so one along with #JoinColumn, so your fields insteed of this
#Column(name = "Graple_1")
public int getGraple_1() {
return graple_1;
}
should be like
#ManyToOne
#JoinColumn(name="Graple1")
public Move getGraple_1() {
return graple_1;
}
This way you will get relevant Move objects and get any data you want from them, along with the requested name
I'm just learning to develop a REST application using JAXB and JPA. I'm stuck in weird problem and I have no clue what to search for.
I have these two classes:
package clinic.model;
import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.persistence.oxm.annotations.XmlInverseReference;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* The persistent class for the patients database table.
*
*/
#Entity
#Table(name="patients")
#NamedQuery(name="Patient.findAll", query="SELECT p FROM Patient p")
#XmlRootElement
public class Patient implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
private String address;
private String area;
#Temporal(TemporalType.DATE)
private Date dob;
private BigDecimal mobile;
private String name;
private String sex;
//bi-directional many-to-one association to Prescription
#OneToMany(mappedBy="patient")
private List<Prescription> prescriptions;
public Patient() {
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getArea() {
return this.area;
}
public void setArea(String area) {
this.area = area;
}
public Date getDob() {
return this.dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public BigDecimal getMobile() {
return this.mobile;
}
public void setMobile(BigDecimal mobile) {
this.mobile = mobile;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
#XmlList
public List<Prescription> getPrescriptions() {
return this.prescriptions;
}
public void setPrescriptions(List<Prescription> prescriptions) {
this.prescriptions = prescriptions;
}
public Prescription addPrescription(Prescription prescription) {
getPrescriptions().add(prescription);
prescription.setPatient(this);
return prescription;
}
public Prescription removePrescription(Prescription prescription) {
getPrescriptions().remove(prescription);
prescription.setPatient(null);
return prescription;
}
}
And
package clinic.model;
import java.io.Serializable;
import javax.persistence.*;
import org.eclipse.persistence.oxm.annotations.XmlInverseReference;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* The persistent class for the prescriptions database table.
*
*/
#Entity
#Table(name="prescriptions")
#NamedQuery(name="Prescription.findAll", query="SELECT p FROM Prescription p")
public class Prescription implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
#Temporal(TemporalType.DATE)
private Date date;
private BigDecimal fee;
#Temporal(TemporalType.DATE)
private Date followup;
private String treatment;
//bi-directional many-to-one association to Patient
#ManyToOne(fetch=FetchType.LAZY)
private Patient patient;
//bi-directional many-to-many association to Diagnosis
#ManyToMany
#JoinTable(
name="prescriptions_diagnoses"
, joinColumns={
#JoinColumn(name="pid")
}
, inverseJoinColumns={
#JoinColumn(name="did")
}
)
private List<Diagnosis> diagnoses;
//bi-directional many-to-one association to PrescriptionDrug
#OneToMany(mappedBy="prescription")
private List<PrescriptionDrug> prescriptionsDrugs;
//bi-directional many-to-many association to Vaccine
#ManyToMany(mappedBy="prescriptions")
private List<Vaccine> vaccines;
public Prescription() {
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public Date getDate() {
return this.date;
}
public void setDate(Date date) {
this.date = date;
}
public BigDecimal getFee() {
return this.fee;
}
public void setFee(BigDecimal fee) {
this.fee = fee;
}
public Date getFollowup() {
return this.followup;
}
public void setFollowup(Date followup) {
this.followup = followup;
}
public String getTreatment() {
return this.treatment;
}
public void setTreatment(String treatment) {
this.treatment = treatment;
}
public Patient getPatient() {
return this.patient;
}
public void setPatient(Patient patient) {
this.patient = patient;
}
public List<Diagnosis> getDiagnoses() {
return this.diagnoses;
}
public void setDiagnoses(List<Diagnosis> diagnoses) {
this.diagnoses = diagnoses;
}
public List<PrescriptionDrug> getPrescriptionsDrugs() {
return this.prescriptionsDrugs;
}
public void setPrescriptionsDrugs(List<PrescriptionDrug> prescriptionsDrugs) {
this.prescriptionsDrugs = prescriptionsDrugs;
}
public PrescriptionDrug addPrescriptionsDrug(PrescriptionDrug prescriptionsDrug) {
getPrescriptionsDrugs().add(prescriptionsDrug);
prescriptionsDrug.setPrescription(this);
return prescriptionsDrug;
}
public PrescriptionDrug removePrescriptionsDrug(PrescriptionDrug prescriptionsDrug) {
getPrescriptionsDrugs().remove(prescriptionsDrug);
prescriptionsDrug.setPrescription(null);
return prescriptionsDrug;
}
public List<Vaccine> getVaccines() {
return this.vaccines;
}
public void setVaccines(List<Vaccine> vaccines) {
this.vaccines = vaccines;
}
}
When I have a patient entry in the database, the service is able to map entities into XML/JSON. But when I add an associating prescription entry, Glassfish throws error 500.
What could be the problem?
I'm using GlassFish 4.0 and EclipseLink 2.5.1. IDE is Eclipse Luna.
Solution found at http://blog.bdoughan.com/2010/07/jpa-entities-to-xml-bidirectional.html
The exception can be seen if a string is returned instead of the POJO object and the marshaling is done manually.