private MapKeyJoinColumn[] getMapKeyJoinColumns(Element element) { List<Element> subelements = element != null ? element.elements( "map-key-join-column" ) : null; List<MapKeyJoinColumn> joinColumns = new ArrayList<MapKeyJoinColumn>(); if ( subelements != null ) { for ( Element subelement : subelements ) { AnnotationDescriptor column = new AnnotationDescriptor( MapKeyJoinColumn.class ); copyStringAttribute( column, subelement, "name", false ); copyStringAttribute( column, subelement, "referenced-column-name", false ); copyBooleanAttribute( column, subelement, "unique" ); copyBooleanAttribute( column, subelement, "nullable" ); copyBooleanAttribute( column, subelement, "insertable" ); copyBooleanAttribute( column, subelement, "updatable" ); copyStringAttribute( column, subelement, "column-definition", false ); copyStringAttribute( column, subelement, "table", false ); joinColumns.add( (MapKeyJoinColumn) AnnotationFactory.create( column ) ); } } return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] ); }
@ManyToMany(fetch = FetchType.LAZY) @MapKeyJoinColumn(name = "REAL_NETWORK_INTERFACE_ID", nullable = false) @JoinTable( name = "SIMULATION__" + "REAL_NETWORK_INTERFACE__" + "REAL_NETWORK_INTERFACE_CONFIGURATION", joinColumns = @JoinColumn(name = "SIMULATION_ID", nullable = false), inverseJoinColumns = @JoinColumn( name = "REAL_NETWORK_INTERFACE_CONFIGURATION_ID", nullable = false ) ) public Map<RealNetworkInterface, RealNetworkInterfaceConfiguration> getRealNetworkInterfaceConfigurations() { return realNetworkInterfaceConfigurations; }
private void buildMapKeyJoinColumns(List<Annotation> annotationList, Element element) { MapKeyJoinColumn[] joinColumns = getMapKeyJoinColumns( element ); if ( joinColumns.length > 0 ) { AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyJoinColumns.class ); ad.setValue( "value", joinColumns ); annotationList.add( AnnotationFactory.create( ad ) ); } }
@OneToMany(mappedBy="portfolio",cascade = {CascadeType.ALL}, fetch = FetchType.EAGER, orphanRemoval=true) @Fetch(FetchMode.SUBSELECT) @MapKeyJoinColumns({ @MapKeyJoinColumn(name="symbol",referencedColumnName="symbol"), @MapKeyJoinColumn(name="isin",referencedColumnName="isin") }) public Map<Stock, PortfolioShare> getListShares() { return listShares; }
private static GeneratorColumn buildKeyColumn(final GeneratorTable table, final MapKeyJoinColumn keyColumn, final String defaultKeyColumn) { if (keyColumn != null && keyColumn.name().length() > 0) { return table.resolveColumn(keyColumn.name()); } return table.resolveColumn(defaultKeyColumn); }
/** * Creates a new map property. * * @param sourceClass * the description of the current inspected class that contains this property * @param attribute * the accessor of the represented attribute * @param override * the configured assocation override */ @SuppressWarnings("unchecked") public MapProperty(final EntityClass<?> sourceClass, final AttributeAccessor attribute, final AssociationOverride override) { super(sourceClass, attribute, override, 1); // Initialize the key description final MapKeyClass keyClassAnnotation = attribute.getAnnotation(MapKeyClass.class); this.keyClass = getPropertyArgument(attribute, keyClassAnnotation != null ? keyClassAnnotation.value() : (Class<K>) void.class, 0); this.keyEntityClass = sourceClass.getContext().getDescription(this.keyClass); if (getMappedBy() != null) { this.keyConverter = null; this.keyColumn = null; } else { if (this.keyEntityClass != null) { // Entity key this.keyConverter = null; this.keyColumn = buildKeyColumn(getTable(), attribute.getAnnotation(MapKeyJoinColumn.class), attribute.getName() + "_KEY"); } else { // Primitive key this.keyConverter = PrimitiveProperty.createConverter(attribute, this.keyClass, true); this.keyColumn = buildKeyColumn(getTable(), attribute.getAnnotation(MapKeyColumn.class), attribute.getName() + "_KEY"); } } }
@ManyToMany(fetch = FetchType.LAZY) @MapKeyJoinColumn(name = "SNMP_AGENT_ID", nullable = false) @JoinTable( name = "SIMULATION__SNMP_AGENT__TRAP_TARGET_GROUP", joinColumns = @JoinColumn(name = "SIMULATION_ID", nullable = false), inverseJoinColumns = @JoinColumn(name = "TRAP_TARGET_GROUP_ID", nullable = false) ) public Map<SnmpAgent, TrapTargetGroup> getTrapTargetGroups() { return trapTargetGroups; }
@ManyToMany(fetch = FetchType.LAZY) @MapKeyJoinColumn(name = "NODE_ID", nullable = false) @JoinTable( name = "SIMULATION__NODE__ADDITIONAL_IP_V4_ROUTE_GROUP", joinColumns = @JoinColumn(name = "SIMULATION_ID", nullable = false), inverseJoinColumns = @JoinColumn(name = "ADDITIONAL_IP_V4_ROUTE_GROUP_ID", nullable = false) ) public Map<Node, AdditionalIpV4RouteGroup> getAdditionalIpV4RouteGroups() { return additionalIpV4RouteGroups; }
@ManyToMany(fetch = FetchType.LAZY) @MapKeyJoinColumn(name = "NODE_ID", nullable = false) @JoinTable( name = "SIMULATION__NODE__ADDITIONAL_IP_V6_ROUTE_GROUP", joinColumns = @JoinColumn(name = "SIMULATION_ID", nullable = false), inverseJoinColumns = @JoinColumn(name = "ADDITIONAL_IP_V6_ROUTE_GROUP_ID", nullable = false) ) public Map<Node, AdditionalIpV6RouteGroup> getAdditionalIpV6RouteGroups() { return additionalIpV6RouteGroups; }
public MapKeyJoinColumnDelegator(MapKeyJoinColumn column) { this.column = column; }