348 words

Beginners questions

#1
2017-02-10 13:12

Hello !!

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

 

1. General questions

1.1. If I understood correctly, ObjectDB is an implementation of JPA standard (currently 2.0)?
1.2. Is ObjectDB on the same level like Hibernate with only difference that Hibernate stores the data in a RDBMS and ObjectDB has its own format?

2. Object creation

I created a class named EBResult which looks like this:

@Entity(name="RESULT")
public class EBResult extends Pojo implements Serializable{.....

In ObjectDB-explorer (which is part of ObjectDB library) I expected to see an object named "RESULT" due to class annotation @Entity(name="RESULT"). Instead I see following:

2.1. Why? Is the @Entity(name="RESULT") ignored by ObjectDB?
2.2. Is the annotation @Entity(name="RESULT") relevant for ObjectDB in any way?

 

3. Object relationship

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

Table "EBVerlag":

@Entity(name="VERLAG")
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":

@Entity(name="USER")
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
caitanya's picture
Joined on 2017-02-10
User Post #1
#2
2017-02-10 16:31

Please split this post to 3 separate threads:

  1. ObjectDB and JPA
  2. Entity name
  3. Relationships and tracking changes

You can post as many questions as you want, but please follow the posting instructions and use a separate thread for every logical subject.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,695
#3
2017-02-10 17:31

I did, sorry

caitanya
caitanya's picture
Joined on 2017-02-10
User Post #5

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.
Attachments:
Maximum file size: 32 MB
Cancel