ObjectDB ObjectDB

Internal Website Search

1-10 of 47 resultsRefresh

Persist error @ManyToMany how to define correct entities relationships

private long id; @ManyToMany(cascade=CascadeType.PERSIST) private List<Category> categories ... .EntityManagerFactory; import javax.persistence.Id; import javax.persistence.ManyToMany; import ... private long id; @ManyToMany(cascade=CascadeType.PERSIST) private List

Removing objects where ManyToMany relationships exist

Consider you have an entity Entity with the following unidirectional relationship: @ManyToMany private Set<OtherEntity> setOfOtherEntities; public Set<OtherEntity> getOtherEntities() { if (setOfOtherEntities == null) { setOfOtherEntities = new TreeSet<OtherEntity>(); } return setOfOtherEntities


javax.persistence Annotation ManyToMany Target: Fields (including property get methods) Defines ... side. If the relationship is bidirectional, the non-owning side must use the mappedBy element of the ManyToMany ... for the relationship, if not defaulted, is specified on the owning side. The ManyToMany annotation may be used


Annotation Element javax.persistence.ManyToMany Class targetEntity (Optional) The entity class that is the target of the association. Optional only if the collection-valued relationship property is defined using Java generics. Must be specified otherwise. Defaults to the parameterized type


Annotation Element javax.persistence.ManyToMany String mappedBy The field that owns the relationship. Required unless the relationship is unidirectional. Default value: "" Since: JPA 1.0


Annotation Element javax.persistence.ManyToMany FetchType fetch (Optional) Whether the association should be lazily loaded or must be eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime that the associated entities must be eagerly fetched. The LAZY strategy


Annotation Element javax.persistence.ManyToMany CascadeType[] cascade (Optional) The operations that must be cascaded to the target of the association. When the target collection is a java.util.Map, the cascade element applies to the map value. Defaults to no operations being cascaded. Default value: {} Since: JPA 1.0

JPA Entity Fields

: OneToOne, ManyToOne - for references of entity types. OneToMany, ManyToMany - for collections and maps

JPA Annotations for Relationships

Reference (JavaDoc) of JPA 2 relationship annotations, including @ManyToMany, @ManyToOne, @OneToMany, @OneToOne, @OrderBy and @MapKey.

Retrieving JPA Entity Objects

an explicit FetchType.EAGER setting: @Entity class Employee { : @ManyToMany(fetch ... in @OneToMany or @ManyToMany annotations (currently ObjectDB does not distinguish between

Getting Started

ObjectDB is very easy to use. Follow the Getting Started Tutorial and the Quick Tour manual chapter and in minutes you may be able to write and run first Java programs against ObjectDB.

Prior knowledge or experience in database programming (SQL, JDBC, ORM, JPA, etc.) is not required, but some background in using the Java language is essential.

Need Help?

  1. Search ObjectDB website
  2. Read the FAQ
  3. Follow the Tutorials
  4. View or post in the forum
  5. Search or file an issue
  6. Contact support