Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDL generation of DbEnumValue uses different strategies for different table #2921

Closed
parveenyadav-multiply opened this issue Jan 3, 2023 · 5 comments

Comments

@parveenyadav-multiply
Copy link
Contributor

Expected behavior

Ebean should use same strategy when generating DDL for DbEnumValue i.e. either use Integer or VarChar, or should honour storage = DbEnumType.VARCHAR when defined

Actual behavior

In my project it is using Integer for some table and VarChar for others even though I have defined storage = DbEnumType.VARCHAR on all enums.

Steps to reproduce

For below enum, ebean uses VarChar

 import io.ebean.annotation.DbEnumType;
import io.ebean.annotation.DbEnumValue;


public enum DeviceOTPTypeEnum {
VALID("VALID"),
VERIFIED("VERIFIED"),
EXPIRED("EXPIRED");

String value;

DeviceOTPTypeEnum(String pValue){
value=pValue;
}


@DbEnumValue(storage = DbEnumType.VARCHAR)
public String getValue() {
return value;
}
}

DDL generated
create table device_otp ( id uuid not null, otp integer not null, verified boolean default false not null, last_sent timestamptz, retry_count integer not null, device_id uuid not null, verified_at timestamptz, version bigint not null, when_created timestamptz not null, last_modified timestamptz not null, deleted boolean default false not null, generated_at timestamptz not null, otp_status varchar(8), constraint ck_device_otp_otp_status check ( otp_status in ('VALID','VERIFIED','EXPIRED')), constraint pk_device_otp primary key (id) );

For below ENUM ebean uses Integer

 import io.ebean.annotation.DbEnumType;
import io.ebean.annotation.DbEnumValue;

public enum UserConsentType {

SMS("SMS"),
EMAIL("EMAIL"),
WHATSAPP("WHATSAPP"),
TERMS_AND_CONDITIONS("TERMS_AND_CONDITIONS"),
CREDIT_REPORT("CREDIT_REPORT");

String value;

UserConsentType(String pValue){
value=pValue;
}

@DbEnumValue(storage = DbEnumType.VARCHAR)
String getValue(){
return value;
}
}

DDL generated
create table device_consents ( id uuid not null, consent_type integer not null, device_id uuid not null, provided boolean default false not null, version bigint not null, when_created timestamptz not null, last_modified timestamptz not null, deleted boolean default false not null, constraint ck_device_consents_consent_type check ( consent_type in (0,1,2,3,4)), constraint pk_device_consents primary key (id) );

@rbygrave
Copy link
Member

Shall we close this? I'm fairly sure you will find another annotation which has meant that it's using the ordinal integer value rather than the expected String values.

@parveenyadav-multiply
Copy link
Contributor Author

@rbygrave I have tried to find, but all the annotations are ebean annotation. Just give me this week, will debug some more and update you

@parveenyadav-multiply
Copy link
Contributor Author

@rbygrave : I have tried to find what is causing the issue, but couldn't I have to change all the DbEnumValue to @Enumerated(EnumType.STRING) to make it work.

You can close the issue.

@rbygrave
Copy link
Member

Can you show us the code for the entities that declared UserConsentType as a field? (The entity code that declared the field of type UserConsentType).

Did this type get used across multiple jars / multiple modules?

Can you tell us the version of Ebean being used here?

@rbygrave rbygrave reopened this Jan 15, 2023
@rbygrave
Copy link
Member

I'll close this for now. Lets reopen if we can come back to it sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants