Skip to content

Antonio112009/Many-To-Many_with_extra_column

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java version Maven version
Hibernate version Spring version
IntelliJ version

Many To Many with extra columns

This is an example of the project based on Vlad Mihalcea's post: The best way to map a many-to-many association with extra columns when using JPA and Hibernate

Stackoverflow questions: Russian:

Before running the project

Warning! The project was developed in the Intellij. It may not be compatible with Eclipse.

  1. Download repository
  2. In file application.properties add database connection properties.
  3. If you are not using MySQL please change database connector in pom.xml (look at the dependencies)

How to run project (IntelliJ)

  1. Open the project
  2. Go to folder ManyToManyWithExtraColumn/src/test/java/com/antonio112009/manyToMany/repository
  3. Open PostRepositoryTest
  4. On the line 19 you will find run button (green arrow right). Press it and watch console.

Fixed issues

  1. [FIXED] Unable to connect 2 or more object (that are in the database). Test number 3.

Error log:

org.springframework.orm.jpa.JpaSystemException: Could not set field value [SHORT_CIRCUIT_INDICATOR] value by reflection : [class com.antonio112009.manyToMany.entity.PostTagId.tagId] 
setter of com.antonio112009.manyToMany.entity.PostTagId.tagId; nested exception is org.hibernate.PropertyAccessException: Could not set field value [SHORT_CIRCUIT_INDICATOR] 
value by reflection : [class com.antonio112009.manyToMany.entity.PostTagId.tagId] setter of com.antonio112009.manyToMany.entity.PostTagId.tagId
  1. [FIXED with crutch] Unable to delete object with multiple objects.

Current issues

  1. if we delete tag by calling deleteByName(tagName), it should delete tag AND remove posts connected to it

About

Example of bidirectional relation ManyToMany with extra column.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages