Java Code Examples for javax.persistence.JoinColumn

The following are top voted examples for showing how to use javax.persistence.JoinColumn. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: lams   File: JPAOverriddenAnnotationReader.java   View source code 7 votes vote down vote up
private void getCollectionTable(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
	Element subelement = element != null ? element.element( "collection-table" ) : null;
	if ( subelement != null ) {
		AnnotationDescriptor annotation = new AnnotationDescriptor( CollectionTable.class );
		copyStringAttribute( annotation, subelement, "name", false );
		copyStringAttribute( annotation, subelement, "catalog", false );
		if ( StringHelper.isNotEmpty( defaults.getCatalog() )
				&& StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) {
			annotation.setValue( "catalog", defaults.getCatalog() );
		}
		copyStringAttribute( annotation, subelement, "schema", false );
		if ( StringHelper.isNotEmpty( defaults.getSchema() )
				&& StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) {
			annotation.setValue( "schema", defaults.getSchema() );
		}
		JoinColumn[] joinColumns = getJoinColumns( subelement, false );
		if ( joinColumns.length > 0 ) {
			annotation.setValue( "joinColumns", joinColumns );
		}
		buildUniqueConstraints( annotation, subelement );
		buildIndex( annotation, subelement );
		annotationList.add( AnnotationFactory.create( annotation ) );
	}
}
 
Example 2
Project: lams   File: AbstractPropertyHolder.java   View source code 6 votes vote down vote up
private void buildHierarchyColumnOverride(XClass element) {
	XClass current = element;
	Map<String, Column[]> columnOverride = new HashMap<String, Column[]>();
	Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>();
	Map<String, JoinTable> joinTableOverride = new HashMap<String, JoinTable>();
	while ( current != null && !mappings.getReflectionManager().toXClass( Object.class ).equals( current ) ) {
		if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class )
				|| current.isAnnotationPresent( Embeddable.class ) ) {
			//FIXME is embeddable override?
			Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath() );
			Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath() );
			Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride( current, getPath() );
			currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
			currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
			currentJoinTableOverride.putAll( joinTableOverride ); //subclasses have precedence over superclasses
			columnOverride = currentOverride;
			joinColumnOverride = currentJoinOverride;
			joinTableOverride = currentJoinTableOverride;
		}
		current = current.getSuperclass();
	}

	holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null;
	holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null;
	holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null;
}
 
Example 3
Project: lams   File: AbstractPropertyHolder.java   View source code 5 votes vote down vote up
/**
 * Get column overriding, property first, then parent, then holder
 */
private JoinColumn[] getExactOverriddenJoinColumn(String propertyName) {
	JoinColumn[] override = null;
	if ( parent != null ) {
		override = parent.getExactOverriddenJoinColumn( propertyName );
	}
	if ( override == null && currentPropertyJoinColumnOverride != null ) {
		override = currentPropertyJoinColumnOverride.get( propertyName );
	}
	if ( override == null && holderJoinColumnOverride != null ) {
		override = holderJoinColumnOverride.get( propertyName );
	}
	return override;
}
 
Example 4
Project: lams   File: Ejb3JoinColumn.java   View source code 5 votes vote down vote up
public static Ejb3JoinColumn[] buildJoinColumns(
		JoinColumn[] anns,
		String mappedBy,
		Map<String, Join> joins,
		PropertyHolder propertyHolder,
		String propertyName,
		Mappings mappings) {
	return buildJoinColumnsWithDefaultColumnSuffix(
			anns, mappedBy, joins, propertyHolder, propertyName, "", mappings
	);
}
 
Example 5
Project: tinyshop8   File: GoodsType8JPA.java   View source code 5 votes vote down vote up
@ManyToOne(targetEntity = GoodsType8JPA.class, cascade = ALL,
          fetch = EAGER)
@JoinColumn(name = "parent_id", foreignKey =
@ForeignKey(name = "fk_parent"))
public GoodsType8JPA getParentType()
{
    return parentType;
}
 
Example 6
Project: financisto1-holo   File: EntityManager.java   View source code 5 votes vote down vote up
private static EntityDefinition parseDefinition(Class<?> clazz) {
	if (!clazz.isAnnotationPresent(Entity.class)) {
		throw new IllegalArgumentException("Class "+clazz+" is not an @Entity");
	}
	EntityDefinition.Builder edb = new EntityDefinition.Builder(clazz);
	try {
		Constructor<?> constructor = clazz.getConstructor();
		edb.withConstructor(constructor);
	} catch (Exception e) {
		throw new IllegalArgumentException("Entity must have an empty constructor");
	}		
	if (clazz.isAnnotationPresent(Table.class)) {
		Table tableAnnotation = clazz.getAnnotation(Table.class);
		edb.withTable(tableAnnotation.name());
	}
	Field[] fields = clazz.getFields();
	if (fields != null) {
		int index = 0;
		for (Field f : fields) {
			if ((f.getModifiers() & Modifier.STATIC) == 0) {
				if (f.isAnnotationPresent(Id.class)) {
					edb.withIdField(parseField(f));
				} else {
					if (f.isAnnotationPresent(Transient.class)) {
						continue;
					} else if (f.isAnnotationPresent(JoinColumn.class)) {
						JoinColumn c = f.getAnnotation(JoinColumn.class);
						edb.withField(FieldInfo.entity(index++, f, c.name(), c.required()));
					} else {
						edb.withField(parseField(f));							
					}						
				}
			}
		}
	}
	return edb.create();
}
 
Example 7
Project: lams   File: JPAOverriddenAnnotationReader.java   View source code 5 votes vote down vote up
private void buildJoinColumns(List<Annotation> annotationList, Element element) {
	JoinColumn[] joinColumns = getJoinColumns( element, false );
	if ( joinColumns.length > 0 ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( JoinColumns.class );
		ad.setValue( "value", joinColumns );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example 8
Project: aws-photosharing-example   File: User.java   View source code 5 votes vote down vote up
@XmlTransient
 @LazyCollection(LazyCollectionOption.EXTRA)
 @ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
 @JoinTable(name = "role_mappings", joinColumns = { 
@JoinColumn(name = "user_id", nullable = false, updatable = false) }, 
inverseJoinColumns = { @JoinColumn(name = "role", 
		nullable = false, updatable = false) })
 public List<Role> getRoles() {return _roles;}
 
Example 9
Project: tianti   File: User.java   View source code 5 votes vote down vote up
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "org_user_role_rel", 
		joinColumns = {@JoinColumn(name = "user_id")}, 
		inverseJoinColumns = {@JoinColumn(name = "role_id")})
@Where(clause="delete_flag=0")
@OrderBy("no")
public Set<Role> getRoles() {
	return roles;
}
 
Example 10
Project: Equella   File: LanguageString.java   View source code 5 votes vote down vote up
@JoinColumn(nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@Index(name = "bundleIndex")
public LanguageBundle getBundle()
{
	return bundle;
}
 
Example 11
Project: tinyshop8   File: GoodsType8JPA.java   View source code 5 votes vote down vote up
@OneToMany(targetEntity = Goods8JPA.class, cascade = ALL,
          fetch = EAGER)
@JoinColumn(name = "join_goods_type_m2o", foreignKey =
@ForeignKey(name = "fk_goods_type_m2o"))
@JoinTable(name = "jpa_goods_type_set", foreignKey =
@ForeignKey(name = "fk_jpa_goods_type_set"))
public Set<Goods8JPA> getGoods8JPASet()
{
    return goods8JPASet;
}
 
Example 12
Project: oasp-tutorial-sources   File: VisitorEntity.java   View source code 5 votes vote down vote up
/**
 * @return code
 */
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "idCode")
public AccessCodeEntity getCode() {

  return this.code;
}
 
Example 13
Project: sbc-qsystem   File: QCustomer.java   View source code 4 votes vote down vote up
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "service_id")
public QService getService() {
    return service;
}
 
Example 14
Project: lemon   File: SendmailAttachment.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TEMPLATE_ID")
public SendmailTemplate getSendmailTemplate() {
    return this.sendmailTemplate;
}
 
Example 15
Project: GitHub   File: OrderDetail.java   View source code 4 votes vote down vote up
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="productCode", nullable=false, insertable=false, updatable=false)
@JsonBackReference("order-product")
public Product getProduct() {
    return this.product;
}
 
Example 16
Project: lemon   File: TaskLog.java   View source code 4 votes vote down vote up
/** @return 外键,任务. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TASK_ID")
public TaskInfo getTaskInfo() {
    return this.taskInfo;
}
 
Example 17
Project: DocIT   File: Employee.java   View source code 4 votes vote down vote up
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="did", nullable=false)
public Department getDepartment() {
    return this.department;
}
 
Example 18
Project: lemon   File: CmsCatalog.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "SITE_ID")
public CmsSite getCmsSite() {
    return this.cmsSite;
}
 
Example 19
Project: lemon   File: ReportDim.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "QUERY_ID")
public ReportQuery getReportQuery() {
    return this.reportQuery;
}
 
Example 20
Project: tianti   File: Article.java   View source code 4 votes vote down vote up
@ManyToOne
@JoinColumn(name = "root_column_info_id")
public ColumnInfo getRootColumnInfo() {
	return rootColumnInfo;
}
 
Example 21
Project: lemon   File: WhitelistService.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PACKAGE_ID")
public WhitelistPackage getWhitelistPackage() {
    return this.whitelistPackage;
}
 
Example 22
Project: lemon   File: BookBorrow.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "INFO_ID")
public BookInfo getBookInfo() {
    return this.bookInfo;
}
 
Example 23
Project: lemon   File: WorkReportAttachment.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "INFO_ID")
public WorkReportInfo getWorkReportInfo() {
    return this.workReportInfo;
}
 
Example 24
Project: lemon   File: BpmConfRule.java   View source code 4 votes vote down vote up
/** @return 外键,配置节点. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "NODE_ID")
public BpmConfNode getBpmConfNode() {
    return this.bpmConfNode;
}
 
Example 25
Project: tap17-muggl-javaee   File: VendorPart.java   View source code 4 votes vote down vote up
@JoinColumn(name="VENDORID")
@ManyToOne
public Vendor getVendor() {
    return vendor;
}
 
Example 26
Project: lemon   File: BpmTaskDef.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROCESS_ID")
public BpmProcess getBpmProcess() {
    return this.bpmProcess;
}
 
Example 27
Project: lemon   File: BpmTaskDefNotice.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TEMPLATE_ID")
public BpmMailTemplate getBpmMailTemplate() {
    return this.bpmMailTemplate;
}
 
Example 28
Project: lemon   File: TemplateField.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "INFO_ID")
public TemplateInfo getTemplateInfo() {
    return this.templateInfo;
}
 
Example 29
Project: lemon   File: BpmProcess.java   View source code 4 votes vote down vote up
/** @return 外键,流程配置. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CONF_BASE_ID")
public BpmConfBase getBpmConfBase() {
    return this.bpmConfBase;
}
 
Example 30
Project: lemon   File: BpmConfNotice.java   View source code 4 votes vote down vote up
/** @return 外键,模板. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TEMPLATE_ID")
public BpmMailTemplate getBpmMailTemplate() {
    return this.bpmMailTemplate;
}
 
Example 31
Project: lemon   File: BpmConfCountersign.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "NODE_ID")
public BpmConfNode getBpmConfNode() {
    return this.bpmConfNode;
}
 
Example 32
Project: java-course   File: BlogEntry.java   View source code 4 votes vote down vote up
/**
 * Returns blog entry author.
 * 
 * @return Blog entry author.
 */
@ManyToOne
@JoinColumn(nullable = false)
public BlogUser getCreator() {
    return creator;
}
 
Example 33
Project: lemon   File: BpmConfForm.java   View source code 4 votes vote down vote up
/** @return 外键,配置节点. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "NODE_ID")
public BpmConfNode getBpmConfNode() {
    return this.bpmConfNode;
}
 
Example 34
Project: lemon   File: BpmConfOperation.java   View source code 4 votes vote down vote up
/** @return 外键,配置节点. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "NODE_ID")
public BpmConfNode getBpmConfNode() {
    return this.bpmConfNode;
}
 
Example 35
Project: lemon   File: CmsTagArticle.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ARTICLE_ID")
public CmsArticle getCmsArticle() {
    return this.cmsArticle;
}
 
Example 36
Project: lemon   File: CmsComment.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ARTICLE_ID")
public CmsArticle getCmsArticle() {
    return this.cmsArticle;
}
 
Example 37
Project: lemon   File: WorkcalRule.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID")
public WorkcalType getWorkcalType() {
    return this.workcalType;
}
 
Example 38
Project: lemon   File: PortalItem.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "INFO_ID")
public PortalInfo getPortalInfo() {
    return this.portalInfo;
}
 
Example 39
Project: lemon   File: PortalItem.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "WIDGET_ID")
public PortalWidget getPortalWidget() {
    return this.portalWidget;
}
 
Example 40
Project: lemon   File: ActivityUser.java   View source code 4 votes vote down vote up
/** @return null. */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "INFO_ID")
public ActivityInfo getActivityInfo() {
    return this.activityInfo;
}