Created
July 12, 2012 19:48
-
-
Save gbadner/3100482 to your computer and use it in GitHub Desktop.
Determining if a backref is needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Remove BackrefAttributeBinding creation from Binder. | |
| Add the following to EntityBinding: | |
| private Set<PluralAttributeKeyBinding> referencingPluralAttributeKeyBindings; | |
| public void addReferencingPluralAttributeKeyBinding(PluralAttributeBinding pluralAttributeKeyBinding) { | |
| referencingPluralAttributeKeyBindings.add( pluralAttributeKeyBinding ); | |
| } | |
| public void completeInitialization() { | |
| for ( PluralAttributeKeyBinding pluralAttributeKeyBinding : referencingPluralAttributeKeyBindings ) { | |
| if ( ! pluralAttributeKeyBinding.isInverse() && | |
| ! pluralAttributeKeyBinding.isNullable() && | |
| getAttributeBindingContainingColumns( | |
| pluralAttributeKeyBinding.getForeignKey().getColumns() | |
| ) == null ) { | |
| create BackRefAttributeBinding; | |
| } | |
| } | |
| } | |
| private SingularAttributeBinding getAttributeBindingContainingColumns( List<Column> columns) { | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment