GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reading-Notes/401-18.md at main · RobbMAlexander/Reading-Notes

Expand file tree

/

401-18.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
53 lines (39 loc) · 1.43 KB
/

401-18.md

Copy path

File metadata and controls

53 lines (39 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions
layout page
title 401.18 Reading Notes
permalink /401-R18/

Web App Security

Many-To-Many

  • In Spring MVC, Many-to-many relationships are established with the annotation @ManyToMany

  • For an SQL database, a join table must be created that includes the respective values used to relate the resources.

  • Within the related Java classes, one will define the join table with @JoinTable annotation and accompanying code block which defines the name of the relational table as well as the respective properties to be included. The class including this annotation with be the joinColumn resource, while the other will be the inverseJoinColumn resource

    • Example from Baeldung guide:

First related class:

@Entity
@Table(name = "Employee")
public class Employee { 
    // ...
 
    @ManyToMany(cascade = { CascadeType.ALL })
    @JoinTable(
        name = "Employee_Project", 
        joinColumns = { @JoinColumn(name = "employee_id") }, 
        inverseJoinColumns = { @JoinColumn(name = "project_id") }
    )
    Set<Project> projects = new HashSet<>();
   
    // standard constructor/getters/setters
}

Second related class:

@Entity
@Table(name = "Project")
public class Project {    
    // ...  
 
    @ManyToMany(mappedBy = "projects")
    private Set<Employee> employees = new HashSet<>();
    
    // standard constructors/getters/setters   
}

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.