Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
decimal
MySQLtype-mapping und EntityGeneratorCustomizerJAVA Beispiel
Data typeRapidClipse default mappingGenerated Javacode (example)

DECIMAL(M,D) [UNSIGNED] [ZEROFILLED]

A

packed exact fixed

packed “exact” fixed-point number.

M is

M is the total number of digits (the precision)

and D is

and D is the number of digits after the decimal

point (the scale). The decimal point and

(for negative numbers)

the “

the “-

” sign

” sign are not

counted

in M. If D is

in M. If D is 0, values have no decimal

point or fractional part.

The maximum number

of digits (M) for

DECIMAL is

DECIMAL is 65. The maximum

number of supported decimals (D) is 30.

If D is

If D is omitted, the default is 0.

If M is

If M is omitted, the

default is 10.

UNSIGNED, if specified, disallows negative values.

All basic calculations (+, -, *, /) with

DECIMAL columns

DECIMAL columns are done with a precision of

65 digits.

Code Block
languagexml
<sql-type jdbc-type="DECIMAL" hibernate-type="java.math.BigDecimal"></sql-type>
Code Block
languagejava
themeConfluence
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"DECIMAL"},new String[]{"java.math.BigDecimal"},"decimal"));
Code Block
languagejava
private BigDecimal decimaltest;
Code Block
languagejava
@Column(name = "DECIMALTEST", nullable = false, 
			precision = 10, scale = 0, columnDefinition = "decimal")
public BigDecimal getDecimaltest() {
	return this.decimaltest;
}



Code Block
languagejava
private Double decimaltest;
Code Block
languagejava
@Column(name = "DECIMALTEST", nullable = false, 
			precision = 10, scale = 0, columnDefinition = "decimal")
public Double getDecimaltest() {
	return this.decimaltest;
}
year

YEAR

A year in four-digit format. MySQL displays

YEAR values in YYYY format

YEAR values in YYYY format, but permits

assignment of values to YEAR columns using

either strings or numbers. Values display

as 1901 to 2155, and 0000

as 1901 to 2155, and 0000.

Code Block
languagejava
themeConfluence
<sql-type jdbc-type="YEAR" hibernate-type="java.lang.String"></sql-type>
Code Block
languagejava
themeConfluence
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"YEAR"},new String[]{"java.lang.String"},"year"));
Code Block
languagejava
private String yeartest;
Code Block
languagejava
@Column(name = "YEARTEST", nullable = false, 
			length = 0, columnDefinition = "year")
public String getYeartest() {
	return this.yeartest;
}
serial

SERIAL

SERIAL is

SERIAL is an alias

for BIGINT

for BIGINT UNSIGNED

-

NOT NULL AUTO_INCREMENT UNIQUE.

-

Hibernate default mapping


Code Block
languagejava
private Long serialtest;
Code Block
languagejava
@GeneratedValue(strategy = IDENTITY)
@Column(name = "SERIALTEST", unique = true, 
			nullable = false)
public Long getSerialtest() {
	return this.serialtest;
}
int

INT(M) [UNSIGNED][ZEROFILLED]

A normal-size integer. The signed range

 

is -

2147483648 to 2147483647

2147483648 to 2147483647.

The unsigned range

is 0 to 4294967295

is 0 to 4294967295.

Code Block
languagexml
<sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Integer"> </sql-type>
-
Code Block
languagejava
private int inttest;
Code Block
languagejava
@Column(name = "INTTEST", nullable = false)
public int getInttest() {
	return this.inttest;
}
varchar columns

VARCHAR

Values in 

VARCHAR

VARCHAR columns are variable-length

strings.

The length can be specified as a value

from 0 to 65,535. The effective maximum

length of a VARCHAR is

length of a VARCHAR is subject to the maximum row

 

size (65,535 bytes, which is shared among all

columns-

columns) and the character set used.

-

Hibernate default mapping


Code Block
languagejava
private String varchartest;
Code Block
languagejava
@Column(name = "VARCHARTEST", nullable = false, 
			length = 10)
public String getVarchartest() {
	return this.varchartest;
}
text

TEXT

A TEXT column with a maximum length of

65,535 (

216 −

216 − 1) characters. The effective

maximum length is less if the value contains

multibyte characters.

Each

TEXT value

TEXT value is

stored using a 2-byte length prefix that

indicates the number of bytes in the value.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(	
	new String[]{"TEXT"},new String[]{"java.lang.String"},"text"));
Code Block
languagejava
private String texttest;
Code Block
languagejava
@Column(name = "TEXTTEST", nullable = false, 
			length = 65535, columnDefinition = "text")
public String getTexttest() {
	return this.texttest;
}
date

DATE

A date. The supported range

is  

is '1000-01-01' to '9999-12-31'.

MySQL

displays

DATE values

DATE values in 'YYYY-MM-DD'

 format

 format,

but permits assignment of values to DATE

-

columns using either strings or numbers.

-

Hibernate default mapping


Code Block
languagejava
private Date datetest;
Code Block
languagejava
@Temporal(TemporalType.DATE)
@Column(name = "DATETEST", nullable = false, 
			length = 10)
public Date getDatetest() {
	return this.datetest;
}
tinyint

TINYINT(M) [UNSIGNED][ZEROFILLED]

A very small integer. The signed range

is  -128 to 127

is -128 to 127. The unsigned range

is 0 to 255

is 0 to 255.

Code Block
languagexml
<sql-type jdbc-type="TINYINT" hibernate-type="java.lang.Short"> </sql-type>
Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"TINYINT","TINYINT UNSIGNED"},
		new String[]{"java.lang.Short","short"},"tinyint"));
Code Block
languagejava
private short tinyinttest;
Code Block
languagejava
@Column(name = "TINYINTTEST", nullable = false, 
			columnDefinition = "tinyint")
public short getTinyinttest() {
	return this.tinyinttest;
}
smallint

SMALLINT(M) [UNSIGNED] [ZEROFILLED]

A small integer. The signed range is -

32768 to  

32768 to 32767. The unsigned range

is 0 to 65535-

is 0 to 65535.

-

Hibernate default mapping


Code Block
languagejava
private short smallinttest;
Code Block
languagejava
@Column(name = "SMALLINTTEST", nullable = false)
public short getSmallinttest() {
	return this.smallinttest;
}
mediumint

MEDIUMINT(M) [UNSIGNED][ZEROFILLED]

A medium-sized integer. The signed range

is  

is -8388608 to 8388607. The unsigned range is 0

-

to 16777215.

-

Hibernate default mapping


Code Block
languagejava
private int mediuminttest;
Code Block
languagejava
@Column(name = "MEDIUMINTTEST", nullable = false)
public int getMediuminttest() {
	return this.mediuminttest;
}
bigint

BIGINT(M) [UNSIGNED][ZEROFILLED]

A large integer. The signed range

is 

 -9223372036854775808 

 to 

is  -9223372036854775808 to 9223372036854775807. The unsigned

 

range

is 0 to -

is 0 to 18446744073709551615.

-

Hibernate default mapping


Code Block
languagejava
private long biginttest;
Code Block
languagejava
@Column(name = "BIGINTTEST", nullable = false)
public long getBiginttest() {
	return this.biginttest;
}
float

FLOAT(M,D) [UNSIGNED][ZEROFILLED]

A small (single-precision) floating-point number.

Permissible values are -3.402823466E+

38 to 

38 to -1.175494351E-38,

 0

 0,

and 1

and 1.175494351E-38

 to 3

to 3.402823466E+38. These are the theoretical

limits, based on the IEEE standard.

The actual

range might be slightly smaller depending on

your hardware or operating system.

M is

M is the total number of digits

and D is

and D is the

number of digits following the decimal point.

If M and D are

If M and D are omitted, values are stored to

the limits permitted by the hardware. A

single-precision floating-point number is

-

accurate to approximately 7 decimal places.

UNSIGNED, if specified, disallows negative values.

-


Hibernate default mapping


Code Block
languagejava
private float floattest;
Code Block
languagejava
@Column(name = "FLOATTEST", nullable = false, 
			precision = 12, scale = 0)
public float getFloattest() {
	return this.floattest;
}
double

DOUBLE(M,D) [UNSIGNED] [ZEROFILLED]

A normal-size (double-precision) floating-point number.

Permissible values are -1.7976931348623157E+308

 to 

to -2.2250738585072014E-308,

 0

 0,

and 

and 2.2250738585072014E-308

 to 

to 1.7976931348623157E+

308

308.

These are the theoretical limits, based on the IEEE standard.

The actual range might be slightly smaller depending on

your hardware or operating system.

M is

M is the total number of digits

and D is

and D is the number of digits

following the decimal point.

If M and D are

If M and D are omitted, values are

stored to the limits permitted by the hardware. A

double-precision floating-point number is accurate to

-

approximately 15 decimal places.

UNSIGNED, if specified, disallows negative values.

-


Hibernate default mapping


Code Block
languagejava
private double doubletest;
Code Block
languagejava
@Column(name = "DOUBLETEST", nullable = false, 
			precision = 22, scale = 0)
public double getDoubletest() {
	return this.doubletest;
}

real

REAL(M,D) [UNSIGNED][ZEROFILLED]

This type is a synonym for DOUBLE.

Exception: If the

 

REAL_AS_FLOAT SQL mode is enabled, REAL is a

synonym for FLOAT

 rather -

 rather than DOUBLE.

-

Hibernate default mapping


Code Block
languagejava
private double realtest;
Code Block
languagejava
@Column(name = "REALTEST", nullable = false, 
			precision = 22, scale = 0)
public double getRealtest() {
	return this.realtest;
}



Code Block
languagejava
private Float realtest;
Code Block
languagejava
@Column(name = "REALTEST", nullable = false, 
			precision = 22, scale = 0)
public Float getRealtest() {
	return this.realtest;
}
bit

BIT(M)

A bit-field type. M indicates the number of bits per

-

value, from 1 to 64.

The default is 1 if M is omitted.

-

Hibernate default mapping


Code Block
languagejava
private boolean bittest;
Code Block
languagejava
@Column(name = "BITTEST", nullable = false)
public boolean isBittest() {
	return this.bittest;
}
boolean

BOOLEAN

These types are synonyms for TINYINT(1). A value

of zero is considered false. Nonzero values are considered

-

true.

-

Hibernate default mapping


Code Block
languagejava
private boolean booleantest;
Code Block
languagejava
@Column(name = "BOOLEANTEST", nullable = false)
public boolean isBooleantest() {
	return this.booleantest;
}
datetime

DATETIME(fsp)

A date and time combination. The supported range is 

'1000-01-01 00:00:00.000000' to 

'9999-12-31 23:59:59.999999'.

MySQL

displays DATETIME values

displays DATETIME values in 'YYYY-MM-DD HH:MM:SS[.

fraction

fraction]'

 format

 format, but permits assignment of values to DATETIME

columns using either strings or numbers.

An optional fsp value in the range from 0 to 6 may be

given to specify fractional seconds precision. A value of

0 signifies that there is no fractional part. If omitted, the

-

default precision is 0.

-


Hibernate default mapping


Code Block
languagejava
private Date datetimetest;
Code Block
languagejava
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATETIMETEST", nullable = false, 
			length = 19)
public Date getDatetimetest() {
	return this.datetimetest;
}
timestamp

TIMESTAMP(fsp)

A timestamp. The range is 

'1970-01-01 00:00:01.000000' UTC to 

'2038-01-19 03:14:07.999999' UTC.

TIMESTAMP

values

values are stored as the number of seconds since the epoch

('1970-01-01 00:00:00' UTC).

A TIMESTAMP cannot

represent the value '1970-01-01 00:00:00' because

that is equivalent to 0 seconds from the epoch and the

value 0 is reserved for representing 

'0000-00-00 00:00:00',

the “zero” -

the “zero” TIMESTAMP value.

-

Hibernate default mapping


Code Block
languagejava
private Date timestamptest;
Code Block
languagejava
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "TIMESTAMPTEST", nullable = false, 
			length = 19)
public Date getTimestamptest() {
	return this.timestamptest;
}
time

TIME(fsp)

A time. The range is '-838:59:59.000000' to 

'838:59:59.000000'.

MySQL displays TIME values in 

'HH:MM:SS[.fraction]' format, but permits assignment

of values to TIME columns using either strings or numbers.

An optional 

fsp value

fsp value in the range from 0 to 6 may be

given to specify fractional seconds precision. A value of 0

signifies that there is no fractional part. If omitted,

-

the default precision is 0.

-


Hibernate default mapping


Code Block
languagejava
private Date timetest;
Code Block
languagejava
@Temporal(TemporalType.TIME)
@Column(name = "TIMETEST", nullable = false, 
			length = 8)
public Date getTimetest() {
	return this.timetest;
}
char

CHAR(M)

Values in CHAR columns are fixed-lenght strings.

The length of a

CHAR column

CHAR column is fixed to the length that you

declare when you create the table. The length can be

any

any value from 0 to 255. When CHAR values are stored, they

are

are right-padded with spaces to the specified length.

-

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

TINYTEXT[CHARACTER SET charset_name]

[COLLATE collation_name]

A TEXT column with a maximum length of 255 (

28 −

28 − 1)

characters. The effective maximum length is less if the

value contains multibyte characters.

Each

TINYTEXTvalue

TINYTEXTvalue is stored using a 1-byte length prefix that

indicates -

indicates the number of bytes in the value.

-

Hibernate default mapping


Code Block
languagejava
private String tinytexttest;
Code Block
languagejava
@Column(name = "TINYTEXTTEST", nullable = false)
public String getTinytexttest() {
	return this.tinytexttest;
}
mediumtext

MEDIUMTEXT[CHARACTER SET charset_name]

[COLLATE collation_name]

A

TEXT column

TEXT column with a maximum length of

16,777,215 (

224 −

224 − 1) characters. The effective maximum

length is less if the value contains multibyte characters.

Each MEDIUMTEXT value is stored using a 3-byte length

prefix that indicates the number of bytes in the value.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"MEDIUMTEXT"},new String[]{"java.lang.String"},"mediumtext"));
Code Block
languagejava
private String mediumtexttest;
Code Block
languagejava
@Column(name = "MEDIUMTEXTTEST", nullable = false, 
			length = 16777215, columnDefinition = "mediumtext")
public String getMediumtexttest() {
	return this.mediumtexttest;
}
longtext

LONGTEXT[CHARACTER SET charset_name]

 [COLLATE collation_name]

A TEXT column with a maximum length of 4,294,967,295

or 4GB (

232 −

232 − 1) characters.

The effective maximum

length is less if the value contains multibyte characters.

The effective maximum length of LONGTEXT

columns

columns also

depends on the configured maximum packet size in the

client/server protocol and available memory.

Each 

 

LONGTEXT value is stored using a 4-byte length prefix

that indicates the number of bytes in the value.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"LONGTEXT"},new String[]{"java.lang.String"},"longtext"));
Code Block
languagejava
private String longtexttest;
Code Block
languagejava
@Column(name = "LONGTEXTTEST", nullable = false, 
			columnDefinition = "longtext")
public String getLongtexttest() {
	return this.longtexttest;
}
binary

BINARY(M)

The BINARY type is similar to the CHAR

type

type, but stores

 

binary byte strings rather than nonbinary character strings. 

 M represents

M represents the column length in bytes.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"BINARY"},new String[]{"byte[]"},"binary"));
Code Block
languagejava
private byte[] binarytest;
Code Block
languagejava
@Column(name = "BINARYTEST", nullable = false, 
			columnDefinition = "binary")
public byte[] getBinarytest() {
	return this.binarytest;
}
varbinary type

VARBINARY(M)

The VARBINARY type is similar to the

VARCHAR

VARCHAR type,

but stores binary byte strings rather than nonbinary

character strings.

 M represents

 M represents the maximum column

-

length in bytes.

-

Hibernate default mapping


Code Block
languagejava
private byte[] varbinarytest;
Code Block
languagejava
@Column(name = "VARBINARYTEST", nullable = false)
public byte[] getVarbinarytest() {
	return this.varbinarytest;
}
tinyblob

TINYBLOB

A BLOB column with a maximum length of 255 (

28 −

28 − 1)

bytes. Each TINYBLOB value is stored using a 1-byte length

-

prefix that indicates the number of bytes in the value.

-

Hibernate default mapping


Code Block
languagejava
private byte[] tinyblobtest;
Code Block
languagejava
@Column(name = "TINYBLOBTEST", nullable = false)
public byte[] getTinyblobtest() {
	return this.tinyblobtest;
}
mediumblob

MEDIUMBLOB

A BLOB column with a maximum length of 16,777,215

(

224 −

224 − 1) bytes. Each MEDIUMBLOB value is stored

using a 3-byte length prefix that indicates the number

of bytes in the value.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"MEDIUMBLOB"},new String[]{"byte[]"},"mediumblob"));
Code Block
languagejava
private byte[] mediumblobtest;
Code Block
languagejava
@Column(name = "MEDIUMBLOBTEST", nullable = false, 
			columnDefinition = "mediumblob")
public byte[] getMediumblobtest() {
	return this.mediumblobtest;
}
blob

BLOB(M)

A BLOB column with a maximum length of 65,535

(

216 −

216 − 1) bytes. Each BLOB value is stored using a

2-byte length prefix that indicates the number of

bytes in the value.

An optional

length M can

length M can be given for this type.

If this is done, MySQL creates the column as the

smallest BLOB ype large enough to hold

values M bytes

values M bytes long.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(	
	new String[]{"BLOB"},new String[]{"byte[]"},"blob"));
Code Block
languagejava
private byte[] blobtest;
Code Block
languagejava
@Column(name = "BLOBTEST", nullable = false, 
			columnDefinition = "blob")
public byte[] getBlobtest() {
	return this.blobtest;
}
longblob

LONGBLOB

A BLOB column with a maximum length of 4,294,967,295

or 4GB (

232 −

232 − 1) bytes. The effective maximum length

of  

of  LONGBLOB columns depends on the configured

maximum

maximum packet size in the client/server protocol and available

 

memory.

Each LONGBLOB value is stored using a 4-byte length

prefix

that

that indicates the number of bytes in the value.

-

Code Block
languagejava
visitor.addPropertyColumnDefinitionFix(new PropertyColumnDefinitionFix(
	new String[]{"LONGBLOB"},new String[]{"byte[]"},"longblob"));
Code Block
languagejava
private byte[] longblobtest;
Code Block
languagejava
@Column(name = "LONGBLOBTEST", nullable = false, 
			columnDefinition = "longblob")
public byte[] getLongblobtest() {
	return this.longblobtest;
}