i want to insert into a table with a specified value,but it just don't work,
here is my code:
#Id
#Column(insertable=true,updatable=true)
public Long getS_id() {
return s_id;
}
#Resource(name="studentService")
private StudentService stus;
Student student = new Student();
student.setS_id(123213L);
student.setName("vincent");
stus.add(student);
If I change:
#Id
#Column(insertable=true,updatable=true)
public Long getS_id() {
return s_id;
}
to this:
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(insertable=true,updatable=true)
public Long getS_id() {
return s_id;
}
and don't set s_id manualy it works well.
here my student class
#Entity()
#Table(name="stu_info")
public class Student implements Serializable{
private static final long serialVersionUID = 1L;
/**
* 学生的学号
*/
private Long s_id;
/**
* 学生姓名
*/
private String name;
/**
* 学生性别
*/
private String sex;
/**
* 学生生日
*/
private Date birthday;
/**
* 学生电话号码
*/
private String telephone;
/**
* 学生所在年级
*/
private String grade;
/**
* 学生所在班级
*/
private String classes;
/**
* 学生编号
*/
private int number;
/**
* 学生父亲姓名
*/
private String father_name;
/**
* 学生母亲姓名
*/
private String mother_name;
/**
* 学生个人疾病史
*/
private String diseases_history;
#Id
#Column(insertable=true,updatable=true)
public Long getS_id() {
return s_id;
}
public void setS_id(Long s_id) {
this.s_id = s_id;
}
#Column(length=32)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
#Column(length=12)
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
#Temporal(TemporalType.DATE)
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
#Column(length=12)
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
#Column(length=32)
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
#Column(length=32)
public String getClasses() {
return classes;
}
public void setClasses(String classes) {
this.classes = classes;
}
#Column(length=32)
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
#Column(length=32)
public String getFather_name() {
return father_name;
}
public void setFather_name(String father_name) {
this.father_name = father_name;
}
#Column(length=32)
public String getMother_name() {
return mother_name;
}
public void setMother_name(String mother_name) {
this.mother_name = mother_name;
}
#Column(length=32)
public String getDiseases_history() {
return diseases_history;
}
public void setDiseases_history(String diseases_history) {
this.diseases_history = diseases_history;
}
}
From the limited information posted I would guess you are using SQL Server and to insert a record into an SQLServer table with an explicit value defined for an Identity column requires you to turn on identity inserts for that table.
https://msdn.microsoft.com/en-gb/library/ms188059.aspx
So if you run the above against your table you should then be able to persist using a specific value.
So not really anything to do with JPA.
Related
i m a total newbie to JPQL ,so i m working on a Spring Boot app and i have this SQL query part :
select TOP 10 RFC_NUMBER, RECIPIENT_ID from [50004].SD_REQUEST S
INNER JOIN [50004].AM_EMPLOYEE E
--ON S.RECIPIENT_ID = E.EMPLOYEE_ID
WHERE E.AVAILABLE_FIELD_5 ='j.doe'
AND SD_REQUEST.STATUS_ID NOT IN (8,6,18,7,24)
AND SD_REQUEST.RFC_NUMBER like 'I%'
to JPQL.
i tried doing a #Query like this :
#Query("select x from Incident x Left join x.recipient recip where recip.login=:login and (x.rfcnumber like :I_% or :rfcnumber = null )"
+ " and x.status NOT IN (8,6,18,7,24)")
but it only returns ALL the rfcnumber of the that employee , i want it to extract only the rfc number starting with letter I ,
i tried doing CONCAT from searching around in then web, same thing.
i m new to this so i figure it'll be something much simpler , i m thinking it's just syntax problem .
Thanks a bunch.
Edit (adding models):
import java.io.Serializable;
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
#Entity
#Table(name="SD_REQUEST")
public class Incident implements Serializable {
private static final long serialVersionUID = -8235081865121541091L;
#Id
#Column(name="REQUEST_ID")
private Integer inid;
#ManyToOne
#JoinColumn(name = "SUBMITTED_BY")
private Employee sender;
#Column(name="RFC_NUMBER")
private String rfcnumber;
#Column(name="CREATION_DATE_UT")
private Date date;
#Column(name="DESCRIPTION")
private String description;
#Column(name="COMMENT")
private String comment;
#Column(name="STATUS_ID")
private Integer status;
#ManyToOne
#JoinColumn(name = "RECIPIENT_ID")
private Employee recipient;
public Incident()
{
}
public Incident(int inid,String rfcnumber,Date date,String description,String comment,Integer status)
{
this.inid=inid;
this.rfcnumber= rfcnumber;
this.date=date;
this.description=description;
this.comment=comment;
this.status=status;
}
public int getInid() {
return inid;
}
public void setInid(int inid) {
this.inid = inid;
}
public String getRfcnumber() {
return rfcnumber;
}
public void setRfcnumber(String rfcnumber) {
this.rfcnumber = rfcnumber;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Employee getSender() {
return sender;
}
public void setSender(Employee sender) {
this.sender = sender;
}
public Employee getRecipient() {
return recipient;
}
public void setRecipient(Employee recipient) {
this.recipient = recipient;
}
public void setInid(Integer inid) {
this.inid = inid;
}
}
And here's the model for Employee :
import javax.persistence.*;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
#Entity
#JsonDeserialize(as =Employee.class)
#Table(name = "AM_EMPLOYEE")
public class Employee implements Serializable {
private static final long serialVersionUID = 5071617893593927440L;
#Id
#Column(name = "EMPLOYEE_ID" )
private Integer id;
#Column(name = "LAST_NAME")
private String lastName;
#Column(name = "AVAILABLE_FIELD_5")
private String login;
#OneToMany(mappedBy="sender")
#JsonIgnore
private List<Incident> myCreatedIncidents;
#OneToMany(mappedBy="recipient")
#JsonIgnore
private List<Incident> myOtherIncidents;
#Column(name = "PASSWD")
private String password;
public Employee() {
//super();
}
public Employee (String login,String password)
{
}
public Employee(Integer id, String lastName,String login, String password) {
this.id = id;
this.lastName = lastName;
this.login = login;
this.password = password;
}
/**
* #return the id
*/
public Integer getId() {
return id;
}
/**
* #param id
* the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* #return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* #param lastName
* the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* #return the login
*/
public String getLogin() {
return login;
}
/**
* #param login
* the login to set
*/
public void setLogin(String login) {
this.login = login;
}
/**
* #return the password
*/
public String getPassword() {
return password;
}
/**
* #param password
* the password to set
*/
public void setPassword(String password) {
this.password = password;
}
public List<Incident> getMyCreatedIncidents() {
return myCreatedIncidents;
}
public void setMyCreatedIncidents(List<Incident> myCreatedIncidents) {
this.myCreatedIncidents = myCreatedIncidents;
}
public List<Incident> getMyOtherIncidents() {
return myOtherIncidents;
}
public void setMyOtherIncidents(List<Incident> myOtherIncidents) {
this.myOtherIncidents = myOtherIncidents;
}
}
Hard-coded characters
I think you should use the same as in SQL:
like 'I%'
Specifically, according to the article # http://www.objectdb.com/java/jpa/query/jpql/string#LIKE_-_String_Pattern_Matching_with_Wildcards_ :
The percent character (%) - which matches zero or more of any character.
Blockquote
So try the following:
#Query("select x from Incident x Left join x.recipient recip where recip.login=:login and (x.rfcnumber like 'I%' or :rfcnumber = null )"
+ " and x.status NOT IN (8,6,18,7,24)"
)
Parameters
See the solutions # Parameter in like clause JPQL if you are using a parameter.
Examples:
LIKE :code%
Also other examples are included in the stackoverflow question.
#Query("select x from Incident x where x.recipient.login=:login and (x.rfcnumber like I% or x.rfcnumber = null )"
+ " and x.status NOT IN (8,6,18,7,24))"
try this query
I have two entities, naming Sport and Image.
As the title above, how can I map the value of property, sportId at Sport to the #ManyToOne collection property at Image? For instance, I want the value of sportId (eg. 1) to be displayed at collection property field of sportId at Image. How can I achieve this?
Sport.java
#Views({#View(members= "title; date; estimatedCost; attendance; remark; images"),
#View(name="NoImagesCollection", members= "sportId; title; date; estimatedCost; attendance; remark")})
#Entity
public class Sport {
//******************************FORM ID******************************//
#Id
#Hidden
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name="SPORT_ID", length=10, unique = true, nullable = false, updatable = false)
private int sportId;
#NoCreate
#NoModify
#OneToMany(fetch = FetchType.LAZY,cascade=CascadeType.ALL,mappedBy="sports")
private Collection<Image> images;
//******************************TITLE******************************//
#Column(name="SPORT_TITLE", precision=2000)
#Required
private String title;
//******************************DATE START******************************//
// #Stereotype("DATE")
#Column(name="SPORT_DATE")
#Required
private Date date;
//******************************ESTIMATED COST******************************//
#Hidden
#Stereotype("MONEY")
#Column(name="SPORT_EST_COST")
#Required
private BigDecimal estimatedCost; // Include the import java.math.* BigDecimal is typically used for money
//******************************ESTIMATED ATTENDEES******************************//
#Hidden
#Column(name="SPORT_ATTENDANCE", length=10)
#Required
private int attendance;
//******************************REMARK******************************//
#Hidden
#Editor("TextAreaNoFrame")
#Stereotype("MEMO")
#Column(name="SPORT_REMARK", precision=2000)
private String remark;
//******************************ENTERED DATE******************************//
#Hidden
#Column(name="ENTERED_DATE")
#Temporal(TemporalType.TIMESTAMP)
private Date enteredDate;
#PrePersist
private void setCreateDate() {
enteredDate = new Date();
}
//******************************MODIFIED DATE******************************//
#Hidden
#Column(name="MODIFIED_DATE")
#Temporal(TemporalType.TIMESTAMP)
private Date modifiedDate;
#PostUpdate
private void updateModifyDate() {
modifiedDate = new Date();
}
//******************************GETTERS AND SETTERS FOR ALL PROPERTIES******************************//
public int getSportId() {
return sportId;
}
public void setSportId(int sportId) {
this.sportId = sportId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public BigDecimal getEstimatedCost() {
return estimatedCost;
}
public void setEstimatedCost(BigDecimal estimatedCost) {
this.estimatedCost = estimatedCost;
}
public int getAttendance() {
return attendance;
}
public void setAttendance(int attendance) {
this.attendance = attendance;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Date getEnteredDate() {
return enteredDate;
}
public void setEnteredDate(Date enteredDate) {
this.enteredDate = enteredDate;
}
public Date getModifiedDate() {
return modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
this.modifiedDate = modifiedDate;
}
public Collection<Image> getImages() {
return images;
}
public void setImages(Collection<Image> images) {
this.images = images;
}
}
Image.java
#View(members="sports; image")
#Entity
public class Image {
#Id
#Hidden
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name="IMG_ID", unique = true, nullable = false, updatable = false)
private int imgId;
#Required
#Column(name="IMG_IMAGE")
#Stereotype("PHOTO")
private byte [] image;
#ReferenceView("NoImagesCollection")
#Required
#NoFrame
#ManyToOne(optional=true)
#JoinColumn(name="IMG_SPORT_ID", nullable = false)
private Sport sports;
#Hidden
#Column(name="ENTERED_DATE")
#Temporal(TemporalType.TIMESTAMP)
private Date penteredDate;
#PrePersist
private void setCreateDate() {
penteredDate = new Date();
}
#Hidden
#Column(name="MODIFIED_DATE")
#Temporal(TemporalType.TIMESTAMP)
private Date pmodifiedDate;
#PostUpdate
private void updateModifyDate() {
pmodifiedDate = new Date();
}
public int getImgId() {
return imgId;
}
public void setImgId(int imgId) {
this.imgId = imgId;
}
public byte[] getImage() {
return image;
}
public void setImage(byte[] image) {
this.image = image;
}
public Sport getSports() {
return sports;
}
public void setSports(Sport sports) {
this.sports = sports;
}
public Date getPenteredDate() {
return penteredDate;
}
public void setPenteredDate(Date penteredDate) {
this.penteredDate = penteredDate;
}
public Date getPmodifiedDate() {
return pmodifiedDate;
}
public void setPmodifiedDate(Date pmodifiedDate) {
this.pmodifiedDate = pmodifiedDate;
}
}
ListSportImagesAction.java
public class ListSportImagesAction extends TabBaseAction implements IForwardAction {
private int row;
#Inject
private Tab tab;
public void execute() throws Exception {
Map sportKey = (Map) tab.getTableModel().getObjectAt(row);
int sportId = ((Integer) sportKey.get("sportId")).intValue();
Tab imageTab = (Tab)getContext().get("CkSurvey", getForwardURI(), "xava_tab");
imageTab.setBaseCondition("${sport.sportId} = " + sportId);
System.out.println("id================="+sportId);
}
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public Tab getTab() {
return tab;
}
public void setTab(Tab tab) {
this.tab = tab;
}
#Override
public String getForwardURI() {
return "/m/Image";
}
#Override
public boolean inNewWindow() {
return true;
}
}
Any guidance provided will be appreciated.
--Edited--
I have added the code for the action that map the value. I fail to display the value at the property field, although it is displayed at Eclipse's console.
i have a rellationship between 2 classes Document and Medecin
#Entity
public class Document implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String annee;
private Date dateVisite;
private String secteur;
private String typeVisite;
#OneToOne( fetch=FetchType.LAZY,cascade=CascadeType.REMOVE)
#JoinColumn(name = "idMedecin")
private Medecin medecin;
public Document(String annee,
Date dateVisite, String secteur, String typeVisite) {
super();
this.annee = annee;
this.dateVisite = dateVisite;
this.secteur = secteur;
this.typeVisite = typeVisite;
}
public String getSecteur() {
return secteur;
}
public void setSecteur(String secteur) {
this.secteur = secteur;
}
public String getTypeVisite() {
return typeVisite;
}
public void setTypeVisite(String typeVisite) {
this.typeVisite = typeVisite;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getAnnee() {
return annee;
}
public void setAnnee(String annee) {
this.annee = annee;
}
public Date getDateVisite() {
return dateVisite;
}
public void setDateVisite(Date dateVisite) {
this.dateVisite = dateVisite;
}
}
and the medecin entity is
#Entity
public class Medecin implements Serializable {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private long id;
private String nom;
private String secteur;
private int telephone;
private int specialite;
public Medecin() {
super();
// TODO Auto-generated constructor stub
}
public Medecin(String nom, String secteur, int telephone, int specialite) {
super();
this.nom = nom;
this.secteur = secteur;
this.telephone = telephone;
this.specialite = specialite;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getSecteur() {
return secteur;
}
public void setSecteur(String secteur) {
this.secteur = secteur;
}
public int getTelephone() {
return telephone;
}
public void setTelephone(int telephone) {
this.telephone = telephone;
}
public int getSpecialite() {
return specialite;
}
public void setSpecialite(int specialite) {
this.specialite = specialite;
}
}
the problem is that after i generate the database i want if i delete the document record from the database i want the medecin record will be deleted also but in my case if i delete the document record the medecin record dont be deleted
Based on your configuration, Hibernate will generate Document table with foreign key pointing to Medicine table.
To achieve your requirement, it should be like:
public class Document {
#OneToOne(mappedBy = "document", cascade = CascadeType.REMOVE)
private Medicine medicine;
}
public class Medicine {
#OneToOne
private Document document;
}
Updated
public void delete(int id){
Document document = entityManager.find(Document.class, id);
entityManager.remove(document);
entityManager.flush();
}
I have three entities, Trader, Portfolio and Member. Each Trader has a Portfolio and a Portfolio can have many Members. I have set up the following relationships. I'm not sure how to use the Jointable that is created, i.e. Portfolio_PORTFOLIOID and members_MEMBERID. Obviously I'd like to associate each portfolid with member id's, however I'm not sure how to go about this. How is the jointable data persisted?
My Portfolio class
#Entity
#Table(name="Portfolio")
#NamedQuery(
name="findPortfolioByTrader",
query="SELECT p FROM Portfolio p" +
" WHERE Trader = :trader"
)
public class Portfolio {
#Id
#GeneratedValue
private Integer portfolioId;
#Temporal(TIMESTAMP)
private Date lastUpdate;
private Integer balance;
private Trader trader;
private Collection<Member> members;
public Portfolio() {
this.lastUpdate = new Date();
}
public Portfolio(Integer balance, Trader trader) {
this.lastUpdate = new Date();
this.balance = balance;
this.trader = trader;
}
public Integer getPortfolioId() {
return portfolioId;
}
public void setPortfolioId(Integer portfolioId) {
this.portfolioId = portfolioId;
}
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
#ManyToMany
#JoinTable(
name="MEMBER_PORTFOLIO",
joinColumns=
#JoinColumn(name="Member_MEMBERID", referencedColumnName="MEMBERID"),
inverseJoinColumns=
#JoinColumn(name="portfolio_PORTFOLIOID", referencedColumnName="PORTFOLIOID")
)
public Collection<Member> getMembers() {
return members;
}
public void setMembers(Collection<Member> members) {
this.members = members;
}
#OneToOne(cascade=ALL, mappedBy="portfolio")
public Trader getTrader()
{
return trader;
}
public void setTrader(Trader trader)
{
this.trader = trader;
}
public Integer getBalance() {
return balance;
}
public void setBalance(Integer balance) {
this.balance = balance;
}
}
My Member class
#Entity
#Table(name="Member")
#NamedQuery(
name="findAllMembers",
query="SELECT m FROM Member m " +
"ORDER BY m.memberId"
)
public class Member implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -468520665316481235L;
private String memberId;
private String forename;
private String surname;
private Integer position;
private Integer majority;
private Integer IPO;
private Integer questions;
private Integer answers;
private Party party;
private Date lastUpdate;
private char status;
private Collection<Portfolio> portfolios;
private Collection<AskOrder> askOrders;
private Collection<BidOrder> bidOrders;
public Member() {
this.lastUpdate = new Date();
}
public Member(String memberId,String forename, String surname, Integer position,
Integer majority, Integer IPO, Integer questions, Integer answers, Party party) {
this.memberId = memberId;
this.forename = forename;
this.surname = surname;
this.position = position;
this.majority = majority;
this.IPO = IPO;
this.questions = questions;
this.answers = answers;
this.party = party;
this.lastUpdate = new Date();
this.askOrders = new ArrayList<AskOrder>();
this.bidOrders = new ArrayList<BidOrder>();
this.portfolios = new ArrayList<Portfolio>();
}
#Id
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public char getStatus() {
return status;
}
public void setStatus(char status) {
this.status = status;
}
#Temporal(TIMESTAMP)
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
public String getForename()
{
return forename;
}
public void setForename(String forename)
{
this.forename = forename;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public Integer getPosition() {
return position;
}
public void setPosition(Integer position) {
this.position = position;
}
public Integer getMajority() {
return majority;
}
public void setMajority(Integer majority) {
this.majority = majority;
}
public Integer getIPO() {
return IPO;
}
public void setIPO(Integer iPO) {
IPO = iPO;
}
public Integer getQuestions() {
return questions;
}
public void setQuestions(Integer questions) {
this.questions = questions;
}
public Integer getAnswers() {
return answers;
}
public void setAnswers(Integer answers) {
this.answers = answers;
}
#ManyToOne
public Party getParty() {
return party;
}
public void setParty(Party party) {
this.party = party;
}
#OneToMany(cascade=ALL, mappedBy="member")
public Collection<AskOrder> getAskOrders()
{
return askOrders;
}
public void setAskOrders(Collection<AskOrder> orders)
{
this.askOrders = orders;
}
#OneToMany(cascade=ALL, mappedBy="member")
public Collection<BidOrder> getBidOrders()
{
return bidOrders;
}
public void setBidOrders(Collection<BidOrder> bidOrders)
{
this.bidOrders = bidOrders;
}
#ManyToMany //FIXME should probably be many to many - done
public Collection<Portfolio> getPortfolios() {
return portfolios;
}
public void setPortfolios(Collection<Portfolio> portfolios) {
this.portfolios = portfolios;
}
}
#Entity
public class Portfolio
{
#Id
#GeneratedValue
private int id;
#ManyToMany
#JoinTable( name = "PortfolioMember",
#JoinColumns : #JoinColumn( name = "Portfolio_ID", referencedColumnName="id" ),
#InverseJoinColumns : #JoinColumn( name = "Member_ID", referencedColumnName="id" )
)
private List<Member> members;
}
#Entity
public class Member
{
#Id
#GeneratedValue
private int id;
#ManyToMany( mappedBy = members )
private List<Portfolio> portfolios;
}
I'm using some JavaFX properties in my app:
#Entity(name = "Klanten")
#Table(name = "Klanten")
#NamedQueries({
#NamedQuery(name = "Klanten.findAll", query = "select k from Klanten k")
})
public class Klant implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private int klantId;
#Transient
private final SimpleStringProperty naam = new SimpleStringProperty();
//private String naam;
//private String straat;
#Transient
private final SimpleStringProperty straat = new SimpleStringProperty();
private String telefoon;
private String huisnummer;
private String gsm;
private String woonplaats;
private String email;
private String postcode;
#OneToMany(mappedBy = "Klant", cascade = CascadeType.REMOVE)
private List<Raam> ramen;
public Klant() {
}
public Klant(String naam) {
this.naam.set(naam);
}
#Override
public String toString() {
return this.naam.get();
}
#Access(AccessType.PROPERTY)
#Column(name="naam")
public String getNaam() {
return this.naam.get();
}
public void setNaam(String naam){
this.naam.set(naam);
}
public List<Raam> getRamen() {
return this.ramen;
}
#Id
public int getKlantId() {
return klantId;
}
public void setKlantId(int klantId) {
this.klantId = klantId;
}
#Access(AccessType.PROPERTY)
#Column(name="straat")
public String getStraat() {
return straat.get();
}
public void setStraat(String straat) {
this.straat.set(straat);
}
public String getTelefoon() {
return telefoon;
}
public void setTelefoon(String telefoon) {
this.telefoon = telefoon;
}
public String getHuisnummer() {
return huisnummer;
}
public void setHuisnummer(String huisnummer) {
this.huisnummer = huisnummer;
}
public String getGsm() {
return gsm;
}
public void setGsm(String gsm) {
this.gsm = gsm;
}
public String getWoonplaats() {
return woonplaats;
}
public void setWoonplaats(String woonplaats) {
this.woonplaats = woonplaats;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPostcode() {
return postcode;
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
public StringProperty naamProperty() {
return naam;
}
public StringProperty straatProperty() {
return straat;
}
}
However when I let JPA generate my database, the column "naam" and "straat" aren't generated. I get no error. How can I resolve this?
I tried all the things listed here:
Possible solution 1
Possible solution 2
These didn't work.
You can try to use regular properties and then have another get method which returns a new SimpleStringProperty, i.e.:
public StringProperty naamProperty() {
return new SimpleStringProperty(naam);
}
public StringProperty straatProperty() {
return new SimpleStringProperty(straat);
}