Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Annotation for fields that relate to other entities via relationships. Works for one-to-one and one-to-many relationships. It is optionally possible to define the relationship type, relationship direction and target class (required for one-many-relationships). Collection based one-to-many relationships return managed collections that reflect addition and removal to the underlying relationships. Examples:
 Collection<Person> friends;
 Person spouse;

Michael Hunger
public @interface RelatedTo {

name of the relationship type, optional, can be inferred from the field name
    String type() default "";


direction for the relationship, by default outgoing
    // FQN is a fix for javac compiler bug

target class, possible to specify it optionally or with use of enforceTargetType
    Class<?> elementClass() default Object.class;

Used to discriminate between relationships with the same type based on end node type (inferred or from elementClass
    boolean enforceTargetType() default false;
New to GrepCode? Check out our FAQ X