Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363693

Summary: updatable=false ignored on ManyToMany join column
Product: z_Archived Reporter: Sam Ratcliff <sam.ratcliff>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P2 CC: sam.ratcliff, sergey.s.sazonov, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Sam Ratcliff CLA 2011-11-14 06:54:50 EST
Build Identifier: 2.3.0

The code below defines the ManyToMany relationship of the parents of node within a directed graph, where a node, X, has parents which are the "from" nodes of the edges which have X as the too node.

@ManyToMany(cascade = CascadeType.REFRESH)
@JoinTable(name = "hierarchy_detail_rel", catalog = "dbo", 
   joinColumns = { @JoinColumn(insertable = false, updatable = false, name = "hierarchy_detail_rel_child") }, 
   inverseJoinColumns = { @JoinColumn(insertable = false, updatable = false, name = "hierarchy_detail_rel_parent") })
private final List<HierarchyDetail> parents;
 
This is included in the class representing the nodes of the graph and the edges are represented by a separate class. The edges cannot be managed automatically (through a class synthesized by eclipselink) as I need to use the HistoryPolicy features within eclipselink. As the edges are managed externally to this relationship, it needs to be read only. It is my understanding that using the "insertable = false, updatable = false" statement on both the join columns should produce the read only behaviour. This appears to work on insert by if the class is part of a cascade merge (potentially a direct JPA merge but not sure) these attributes are ignored.

The only way round it was to use a DescriptorCustomizer with the below :
   @Override
    public void customize(ClassDescriptor descriptor) {
     
        ManyToManyMapping parentMapping = (ManyToManyMapping) descriptor.getMappingForAttributeName("parents");
        parentMapping.setIsReadOnly(true);
 
    }

Reproducible: Always

Steps to Reproduce:
1.Create a manytomany relationship with a separate relationship class which has cascade merge on the two foreign keys
2.Persist two elements to be related
3.Persist the relationship object 
4.Merge the relationship object
Comment 1 Tom Ware CLA 2011-11-24 15:26:13 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Sergey Sazonov CLA 2022-03-22 07:40:23 EDT
Are there any updates? Issue is still reproducing.
Comment 3 Alex K CLA 2022-03-22 08:06:44 EDT
Yeah, would be great to finally get this very irritating bug fixed.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:25:19 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink