All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fuchss.objectcasket.objectpacker.impl.M2MInfo Maven / Gradle / Ivy

Go to download

Object Casket is a simple O/R mapper that can be used together with the Java Persistence API (JPA). The aim is to provide a simple solution for small projects to store multi-related entities in a simple manner.

There is a newer version: 0.20.17
Show newest version
package org.fuchss.objectcasket.objectpacker.impl;

import jakarta.persistence.*;

@Entity()
@Table(name = "Many@Many")
final class M2MInfo {

	static final String FIELD_CLIENT_TABLE_NAME = "clientTableName";
	static final String FIELD_CLIENT_COLUMN_NAME = "clientColumnName";
	static final String FIELD_JOIN_TABLE_NAME = "joinTableName";

	static final String COL_CLIENT_TABLE_NAME = "client@TableName";
	static final String COL_CLIENT_COLUMN_NAME = "client@ColumnName";
	static final String COL_SUPPLIER_TABLE_NAME = "supplier@TableName";
	static final String COL_JOIN_TABLE_NAME = "join@TableTableName";

	@Id
	@GeneratedValue
	private Integer id;

	@Column(name = COL_CLIENT_TABLE_NAME)
	private String clientTableName;

	@Column(name = COL_CLIENT_COLUMN_NAME)
	private String clientColumnName;

	@Column(name = COL_SUPPLIER_TABLE_NAME)
	private String supplierTableName;

	@Column(name = COL_JOIN_TABLE_NAME)
	private String joinTableName;

	@Transient
	private Class clientClass;

	@Transient
	private ClassInfo clientClassInfo;

	@Transient
	private Class supplierClass;

	@Transient
	private ClassInfo supplierClassInfo;

	@SuppressWarnings("unused")
	private M2MInfo() {
	}

	M2MInfo(String clientTableName, String clientColumnName, String supplierTableName, String joinTableName) {
		this.clientTableName = clientTableName;
		this.clientColumnName = clientColumnName;
		this.supplierTableName = supplierTableName;
		this.joinTableName = joinTableName;
	}

	void init(ClassInfo clientInfo, ClassInfo supplierInfo) {
		this.clientClassInfo = clientInfo;
		this.supplierClassInfo = supplierInfo;
		this.clientClass = this.clientClassInfo.myClass;
		this.supplierClass = this.supplierClassInfo.myClass;

	}

	String getClientTableName() {
		return this.clientTableName;
	}

	String getClientColumnName() {
		return this.clientColumnName;
	}

	String getSupplierTableName() {
		return this.supplierTableName;
	}

	String getJoinTableName() {
		return this.joinTableName;
	}

	Class getClientClass() {
		return this.clientClass;
	}

	ClassInfo getClientClassInfo() {
		return this.clientClassInfo;
	}

	Class getSupplierClass() {
		return this.supplierClass;
	}

	ClassInfo getSupplierClassInfo() {
		return this.supplierClassInfo;
	}

}