234 words

Relationships and tracking changes

2017-02-10 17:29

Hello !!

I am new in JPA / ObjectDB development and I have many questions:


3. Object relationship

I try to create a 1->n relation (EBVerlag is 1 and EBUser is n) between two tables:

Table "EBVerlag":

public class EBVerlag extends Pojo implements Serializable {
private static final long serialVersionUID = 1L;
@Id @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO)  private Long id;
@OneToMany (fetch=FetchType.LAZY,cascade=CascadeType.ALL, mappedBy="VERLAG_ID") private List<EBUser> users;

Table "EBUser":

public class EBUser extends Pojo implements Serializable{
private static final long serialVersionUID = 1L;
@Id @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) private Long id;
@ManyToOne @Column(name = "VERLAG_ID") @JoinColumn(name="VERLAG_ID", insertable=false, updatable=false) private EBVerlag verlag=null;

3.1. Please take a look at column names and tell me, if I did the connection between these two tables correctly or not.

3.2. Both POJO-s extend my own class "Pojo.class" which looks like this:

public class Pojo {
private transient boolean changed=false;
public boolean isChanged(){
  return changed;
public void setChanged(boolean changed){
  this.changed = changed;

...as you can see, I tried to manage changes inside of the tables by the hand. So let's say: if I call a set-method of my POJO and the new value is different than the old value, then I call setChanged(true). Is there a better way to manage such changes (maybe automatically?). Please consider that I cannot use Spring or similar, because the test-project works inside of GWT-context.

caitanya's picture
Joined on 2017-02-10
User Post #4
2017-02-12 10:55
support's picture
Joined on 2010-05-03
User Post #2,699

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB