Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Oracletype-mapping und EntityGeneratorCustomizerJAVA Beispiel

binary_float

Is a 32-bit, single-precision floating-point number
datatype. Each BINARY_FLOAT value requires 5
bytes, including a length byte.

<sql-type jdbc-type="NUMERIC" name="binary_float" 
	hibernate-type="java.lang.Float" />
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"BINARY_FLOAT"},new String[]
		{"java.lang.FLOAT","float"},"binary_float"));
private Float binaryfloattest;
@Column(name = "BINARYFLOATTEST", columnDefinition = "binary_float")
public Float getBinaryfloattest() {
	return this.binaryfloattest;
}

binary_double

Is a 64-bit, double-precision floating-point number
datatype. Each BINARY_DOUBLE value requires 9
bytes, including a length byte.

<sql-type jdbc-type="NUMERIC" name="binary_double" 
	hibernate-type="java.lang.Double" />
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"BINARY_DOUBLE"},new String[]
		{"java.lang.DOUBLE","double"},"binary_double"));
private Float binarydoubletest;
@Column(name = "BINARYDOUBLETEST", columnDefinition = "binary_double")
public Double getBinarydoubletest() {
	return this.binarydoubletest;
}

rowid

 Store the addresses of rows in ordinary tables.

<sql-type jdbc-type="CHAR" name="rowid" 
		hibernate-type="java.lang.Float" />
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"ROWID"},new String[]{"java.lang.String"},"rowid"));
private String rowidtest;
@Column(name = "ROWIDTEST", columnDefinition = "rowid")
public String getRowidtest() {
	return this.rowidtest;
}

long

 Columns defined as LONG can store variable-length

 character data containingup to 2 gigabytes of

 information. LONG data is text data that is to be

 appropriately converted when moving among

 different systems.

-

visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"LONG"},new String[]{"java.lang.String"},"long"));
private String longtest;
@Column(name = "LONGTEST", length = 0, 
			columnDefinition = "long")
public String getLongtest() {
	return this.longtest;
}

nchar(n)

 The NCHAR datatype stores fixed-length

 character strings that correspond to the

 national character set.

-

visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"NCHAR"},new String[]{"java.lang.String"},"nchar"));
private String nchartest;
@Column(name = "NCHARTEST", length = 10, 
			columnDefinition = "nchar")
public String getNchartest() {
	return this.nchartest;
}

nclob

 NCLOB datatype stores up to 128 terabytes

 of character data in the database. 

 NCLOBs store Unicode national character set data.

-

visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"NCLOB"},new String[]{"java.lang.String"},"nclob"))
		.addLobAnnotation());;
private String nclobtest;
@Lob
@Column(name = "NCLOBTEST", columnDefinition = "nclob")
public String getNclobtest() {
	return this.nclobtest;
}

char(n)

The CHAR datatype stores fixed-length character strings.

 When you create a table with a CHAR column, you must

 specify a string length (in bytes or characters) between

 1 and 2000 bytes for the CHAR column width. The

 default is 1 byte.

-

visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"CHAR"},new String[]{"java.lang.String"},"char"));
private String chartest;
@Column(name = "CHARTEST", length = 10, 
			columnDefinition = "char")
public String getChartest() {
	return this.chartest;
}

varchar

The VARCHAR datatype is synonymous with the

 VARCHAR2 datatype. To avoid possible changes

 in behavior, always use the VARCHAR2 datatype to

 store variable-length character strings.

-

-

private String varchartest;
@Column(name = "VARCHARTEST", length = 10)
public String getVarchartest() {
	return this.varchartest;
}

nvarchar2

NVARCHAR2 is a Unicode datatype that

 store Unicode character data. The character set

 NVARCHAR2 datatype can only be either 

 AL16UTF16 or UTF8 and is specified at

 database creation time as the national character

 set. AL16UTF16 and UTF8 are both Unicode encoding.

-

visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"NVARCHAR2"},new String[]{"java.lang.String"},"nvarchar2"));
private String nvarchar2test;
@Column(name = "NVARCHAR2TEST", length = 10, 
			columnDefinition = "nvarchar2")
public String getNvarchar2test() {
	return this.nvarchar2test;
}

varchar2

The VARCHAR2 datatype stores variable-length character

 strings. When you create a table with a VARCHAR2

 column, you specify a maximum string length (in bytes or

 characters) between 1 and 4000 bytes for the VARCHAR2

 column. For each row, Oracle Database stores each value

 in the column as a variable-length field unless a value

 exceeds the column's maximum length, in which case

 Oracle Database returns an error.

-

-

private String varchar2test;
@Column(name = "VARCHAR2TEST", length = 10")
public String getVarchar2test() {
	return this.varchar2test;
}

clob

The CLOB datatype stores up to 128 terabytes

 of character data in the database. CLOBs store database

 character set data.

<sql-type jdbc-type="CLOB" hibernate-type="java.lang.String" />
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"CLOB"},new String[]{"java.lang.String"},"clob")
		.addLobAnnotation());
private String clobtest;
@Lob
@Column(name = "CLOBTEST", columnDefinition = "clob")
public String getClobtest() {
	return this.clobtest;
}

number

The NUMBER datatype stores fixed and floating-point

 numbers. Numbers of virtually any magnitude can be

 stored and are guaranteed portable among different

 systems operating Oracle Database, up to 38 digits

 of precision.

<sql-type jdbc-type="NUMERIC" name="number" 
	hibernate-type="java.lang.Double" />
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"NUMBER"},new String[]
		{"java.lang.Double","double"},"number"));
private Double numbertest;
@Column(name = "NUMBERTEST", precision = 22, 
			scale = 0)
public Double getNumbertest() {
	return this.numbertest;
}

date

The DATE datatype stores point-in-time values (dates

and times) in a table. The DATE datatype stores the

year (including the century), the month, the day, the

hours, the minutes, and the seconds (after midnight).

Oracle Database can store dates in the Julian era,

ranging from January 1, 4712 BCE through December

31, 9999 CE (Common Era, or 'AD'). Unless BCE

('BC' in the format mask) is specifically used, CE date

entries are the default.

Oracle Database uses its own internal format to store

dates. Date data is stored in fixed-length fields of seven

bytes each, corresponding to century, year, month, day,

hour, minute, and second.

 -

-

private Date datetest;
@Temporal(TemporalType.DATE)
@Column(name = "DATETEST", length = 7)
public Date getDatetest() {
	return this.datetest;
}
timestamp

-

-

private Date timestamptest;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "TIMESTAMPTEST")
public Date getTimestamptest() {
	return this.timestamptest;
}

blob

The BLOB datatype stores unstructured binary data in

 the database. BLOBs can store up to 128 terabytes of

 binary data.

<sql-type jdbc-type="BLOB" hibernate-type="byte[]" />
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"BLOB"},new String[]{"byte[]"},"blob"));
package com.company.example.entities;

import static javax.persistence.GenerationType.IDENTITY;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.company.example.dal.ProductDAO;
import com.xdev.dal.DAO;
import com.xdev.util.Caption;

/**
 * Product
 */
@DAO(daoClass = ProductDAO.class)
@Caption("{%productname}")
@Entity
@Table(name = "PRODUCTS", schema = "PUBLIC", catalog = "NORTHWIND")
public class Product implements java.io.Serializable {

	private Integer productid;
	private Category category;
	private Supplier supplier;
	private String productname;
	private String quantityperunit;
	private BigDecimal unitprice;
	private Short unitsinstock;
	private Short unitsonorder;
	private Short reorderlevel;
	private boolean discontinued;
	private Set<Orderdetail> orderdetails = new HashSet<>(0);
	public Product() {
	}

	public Product(final String productname, final boolean discontinued) {
		this.productname = productname;
		this.discontinued = discontinued;
	}

	public Product(final Category category, final Supplier supplier, final String productname, final String quantityperunit,
			final BigDecimal unitprice, final Short unitsinstock, final Short unitsonorder, final Short reorderlevel, final boolean discontinued,
			final Set<Orderdetail> orderdetails) {
		this.category = category;
		this.supplier = supplier;
		this.productname = productname;
		this.quantityperunit = quantityperunit;
		this.unitprice = unitprice;
		this.unitsinstock = unitsinstock;
		this.unitsonorder = unitsonorder;
		this.reorderlevel = reorderlevel;
		this.discontinued = discontinued;
		this.orderdetails = orderdetails;
	}

	@Caption("Productid")
	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "PRODUCTID", unique = true, nullable = false, columnDefinition = "INTEGER")
	public Integer getProductid() {
		return this.productid;
	}

	public void setProductid(final Integer productid) {
		this.productid = productid;
	}

	@Caption("Category")
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CATEGORYID", columnDefinition = "INTEGER")
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(final Category category) {
		this.category = category;
	}

	@Caption("Supplier")
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "SUPPLIERID", columnDefinition = "INTEGER")
	public Supplier getSupplier() {
		return this.supplier;
	}

	public void setSupplier(final Supplier supplier) {
		this.supplier = supplier;
	}

	@Caption("Productname")
	@Column(name = "PRODUCTNAME", nullable = false, columnDefinition = "VARCHAR", length = 40)
	public String getProductname() {
		return this.productname;
	}

	public void setProductname(final String productname) {
		this.productname = productname;
	}

	@Caption("Quantityperunit")
	@Column(name = "QUANTITYPERUNIT", columnDefinition = "VARCHAR", length = 20)
	public String getQuantityperunit() {
		return this.quantityperunit;
	}

	public void setQuantityperunit(final String quantityperunit) {
		this.quantityperunit = quantityperunit;
	}

	@Caption("Unitprice")
	@Column(name = "UNITPRICE", columnDefinition = "DECIMAL", precision = 10, scale = 4)
	public BigDecimal getUnitprice() {
		return this.unitprice;
	}

	public void setUnitprice(final BigDecimal unitprice) {
		this.unitprice = unitprice;
	}

	@Caption("Unitsinstock")
	@Column(name = "UNITSINSTOCK", columnDefinition = "SMALLINT")
	public Short getUnitsinstock() {
		return this.unitsinstock;
	}

	public void setUnitsinstock(final Short unitsinstock) {
		this.unitsinstock = unitsinstock;
	}

	@Caption("Unitsonorder")
	@Column(name = "UNITSONORDER", columnDefinition = "SMALLINT")
	public Short getUnitsonorder() {
		return this.unitsonorder;
	}

	public void setUnitsonorder(final Short unitsonorder) {
		this.unitsonorder = unitsonorder;
	}

	@Caption("Reorderlevel")
	@Column(name = "REORDERLEVEL", columnDefinition = "SMALLINT")
	public Short getReorderlevel() {
		return this.reorderlevel;
	}

	public void setReorderlevel(final Short reorderlevel) {
		this.reorderlevel = reorderlevel;
	}

	@Caption("Discontinued")
	@Column(name = "DISCONTINUED", nullable = false, columnDefinition = "BOOLEAN")
	public boolean isDiscontinued() {
		return this.discontinued;
	}

	public void setDiscontinued(final boolean discontinued) {
		this.discontinued = discontinued;
	}

	@Caption("Orderdetails")
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product")
	public Set<Orderdetail> getOrderdetails() {
		return this.orderdetails;
	}

	public void setOrderdetails(final Set<Orderdetail> orderdetails) {
		this.orderdetails = orderdetails;
	}

}

private byte[] blobtest;
@Column(name = "BLOBTEST", columnDefinition = "blob")
public byte[] getBlobtest() {
	return this.blobtest;
}
  • No labels