mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-25 07:57:39 +00:00
[utf8mb4-support] limited the size of all indexed string columns, as max key length on mysql/mariadb is 767 bytes (which are <= 191 chars on utf8mb4) (#1264)
This commit is contained in:
committed by
Rob Bygrave
parent
a1d0fbb194
commit
b8aa822a30
@@ -8,6 +8,8 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@@ -29,9 +31,11 @@ public class EBasic {
|
||||
Integer id;
|
||||
|
||||
Status status;
|
||||
|
||||
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@Size(max=127)
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
@@ -42,28 +46,34 @@ public class EBasic {
|
||||
|
||||
@ManyToOne
|
||||
ERef eref;
|
||||
|
||||
|
||||
|
||||
|
||||
// test add & remove indices
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String indextest1;
|
||||
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest2;
|
||||
|
||||
|
||||
@Size(max=127)
|
||||
String indextest3;
|
||||
|
||||
|
||||
@Size(max=127)
|
||||
String indextest4;
|
||||
|
||||
|
||||
@Index(unique = false)
|
||||
@Size(max=127)
|
||||
String indextest5;
|
||||
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest6;
|
||||
|
||||
|
||||
@NotNull
|
||||
int user_id;
|
||||
|
||||
|
||||
public EBasic() {
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@@ -51,11 +52,13 @@ public class EBasic {
|
||||
Status status;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
|
||||
@DbMigration(preAlter = "-- rename all collisions")
|
||||
@Column(unique = true)
|
||||
@Size(max=127)
|
||||
String description;
|
||||
|
||||
@NotNull
|
||||
@@ -75,20 +78,26 @@ public class EBasic {
|
||||
@DbDefault("true")
|
||||
boolean newBooleanField2;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest1;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest2;
|
||||
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String indextest3;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest4;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest5;
|
||||
|
||||
@Index(unique = false)
|
||||
@Size(max=127)
|
||||
String indextest6;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -9,6 +9,8 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@@ -30,9 +32,11 @@ public class EBasic {
|
||||
Integer id;
|
||||
|
||||
Status status;
|
||||
|
||||
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@Size(max=127)
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
@@ -47,21 +51,27 @@ public class EBasic {
|
||||
|
||||
// test add & remove indices
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String indextest1;
|
||||
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest2;
|
||||
|
||||
|
||||
@Size(max=127)
|
||||
String indextest3;
|
||||
|
||||
|
||||
@Size(max=127)
|
||||
String indextest4;
|
||||
|
||||
|
||||
@Index(unique = false)
|
||||
@Size(max=127)
|
||||
String indextest5;
|
||||
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest6;
|
||||
|
||||
|
||||
@NotNull
|
||||
@DbDefault("23")
|
||||
int user_id;
|
||||
|
||||
@@ -2,12 +2,16 @@ package org.tests.compositekeys.db;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
|
||||
@Embeddable
|
||||
public class ItemKey {
|
||||
@Size(max=127)
|
||||
private int customer;
|
||||
|
||||
@Column(name = "itemNumber")
|
||||
@Column(name = "itemnumber")
|
||||
@Size(max=127)
|
||||
private String itemNumber;
|
||||
|
||||
public int getCustomer() {
|
||||
|
||||
@@ -4,6 +4,8 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@@ -13,6 +15,7 @@ public class BWithQIdent {
|
||||
Integer id;
|
||||
|
||||
@Column(name = "`Name`", unique = true)
|
||||
@Size(max = 191) // key must not exceed 767 Bytes, so max key len for mysql with utf8mb4 = 191*4 = 764 bytes
|
||||
String name;
|
||||
|
||||
@Version
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
Integer oneKey;
|
||||
@Size(max = 127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
@@ -13,6 +13,8 @@ import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,7 +28,10 @@ public class Contact {
|
||||
@Id
|
||||
int id;
|
||||
|
||||
@Size(max=127)
|
||||
String firstName;
|
||||
|
||||
@Size(max=127)
|
||||
String lastName;
|
||||
|
||||
String phone;
|
||||
|
||||
@@ -6,6 +6,8 @@ import io.ebean.annotation.Index;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@@ -29,6 +31,7 @@ public class EBasic {
|
||||
Status status;
|
||||
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
@@ -6,6 +6,8 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@@ -17,10 +19,15 @@ public class EBasicWithUniqueCon {
|
||||
Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@Size(max=127)
|
||||
String other;
|
||||
|
||||
@Size(max=127)
|
||||
String otherOne;
|
||||
|
||||
String description;
|
||||
|
||||
@Version
|
||||
|
||||
@@ -3,12 +3,14 @@ package org.tests.model.basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Entity
|
||||
public class ECustomId {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "shortUid")
|
||||
@Size(max=127)
|
||||
String id;
|
||||
|
||||
String name;
|
||||
|
||||
@@ -8,6 +8,7 @@ import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* A basic entity to test simple things.
|
||||
@@ -26,6 +27,7 @@ public class TSDetail {
|
||||
String description;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String someUniqueValue;
|
||||
|
||||
boolean active;
|
||||
|
||||
@@ -8,6 +8,8 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@@ -17,6 +19,7 @@ import java.util.List;
|
||||
public class TCar {
|
||||
|
||||
@Id
|
||||
@Size(max=32)
|
||||
String plateNo;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
|
||||
@@ -2,10 +2,15 @@ package org.tests.model.composite;
|
||||
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class RCustomerKey {
|
||||
|
||||
@Size(max=127)
|
||||
private String company;
|
||||
|
||||
@Size(max=127)
|
||||
private String name;
|
||||
|
||||
public RCustomerKey() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinColumns;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,7 @@ public class ROrder {
|
||||
private RCustomer customer;
|
||||
|
||||
@Column(name = "customerName")
|
||||
@Size(max=127)
|
||||
private String customerName;
|
||||
|
||||
private String item;
|
||||
|
||||
@@ -4,6 +4,7 @@ package org.tests.model.composite;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* @author rnentjes
|
||||
@@ -12,8 +13,10 @@ import javax.persistence.Embeddable;
|
||||
public class ROrderPK implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7632735517186104883L;
|
||||
|
||||
@Size(max=127)
|
||||
private String company;
|
||||
|
||||
@Size(max=127)
|
||||
private Integer orderNumber;
|
||||
|
||||
public ROrderPK() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,6 +20,7 @@ public class Document extends BaseDomain {
|
||||
public static DocumentFinder find = new DocumentFinder();
|
||||
|
||||
@Column(unique = true)
|
||||
@Size(max=127)
|
||||
String title;
|
||||
|
||||
String body;
|
||||
|
||||
@@ -7,6 +7,8 @@ import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@@ -19,6 +21,7 @@ public class OrderEntity {
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "uuid")
|
||||
@Size(max=40)
|
||||
private String id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "order")
|
||||
|
||||
@@ -6,6 +6,8 @@ import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Entity
|
||||
@@ -18,6 +20,7 @@ public class OrderItemEntity {
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "uuid")
|
||||
@Size(max=40)
|
||||
private String id;
|
||||
|
||||
@Column(name = "product_variant_uuid")
|
||||
|
||||
@@ -5,6 +5,8 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@@ -17,6 +19,7 @@ public class Wview {
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(unique = true)
|
||||
@Size(max=127)
|
||||
private String name;
|
||||
|
||||
public UUID getId() {
|
||||
|
||||
@@ -6,6 +6,8 @@ import io.ebean.annotation.WhenModified;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@@ -16,6 +18,7 @@ public class EPersonOnline {
|
||||
Long id;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String email;
|
||||
|
||||
boolean online;
|
||||
|
||||
Reference in New Issue
Block a user