How to enum mapping with jpa Spring boot why not save enum value in DB in DB saving enum key





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-2















import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;

import com.lue.billingsystem.enums.Status;
import com.lue.billingsystem.enums.Types;

@Entity
@Table(name="product_tab")
public class Product implements Serializable{

private static final long serialVersionUID = 8919320309645697466L;

@Id
@Column(name="prod_id",updatable=false)
@GenericGenerator(name="product_tab_genetator",strategy="increment")
@GeneratedValue(generator="product_tab_genetator")
private Long id;

private String name;

@Enumerated(EnumType.STRING)
@Column(name = "type")
private Types type;

@Column(name = "status")
@Enumerated(EnumType.STRING)
private Status status;

@Column(name = "description", length = 200)
private String description;

@OneToMany(mappedBy="product")
private List<Charge> charges;


@Column(name = "create_date", columnDefinition = "DATETIME")
private Date createDate;

@Column(name = "update_date", columnDefinition = "DATETIME")
private Date updateDate;

//@Version
private Integer version;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Types getType() {
return type;
}
public void setType(Types type) {
this.type = type;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Charge> getCharges() {
return charges;
}
public void setCharges(List<Charge> charges) {
this.charges = charges;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}


}





import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.lue.billingsystem.enums.utils.StatusDeserializer;
import com.lue.billingsystem.exception.BillingException;

@JsonDeserialize(using = StatusDeserializer.class)
public enum Status {
ACTIVE("Active"), INACTIVE("Inactive");

private final String text;

Status(final String text) {
this.text = text;
}

@Override
public String toString() {
return text;
}

public String getText() {
return this.text;
}

public static Status fromText(String text) {
for (Status r : Status.values()) {
if (r.getText().equals(text)) {
System.out.println(r);
return r;
}
}
throw new BillingException("Your Status not valied: "+text +" ", HttpStatus.BAD_REQUEST, 400);
}

}


import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.lue.billingsystem.enums.Status;

public class StatusDeserializer extends JsonDeserializer<Status> {

@Override
public Status deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {

ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);

if (node == null) {
return null;
}

String text = node.textValue(); // gives "A" from the request

if (text == null) {
return null;
}
//System.out.println(Status.fromText(text) + "---------------");
return Status.fromText(text);
}

}


How to enum mapping with jpa Spring boot why not save enum value in DB in DB saving enum key when i saving product in databse not save status like Active it always save ACTIVE










share|improve this question




















  • 2





    Repeating your question four times to get around the 'too little text' pop up, isn't making your question any clearer. Please instead elaborate on your problem and give a description.

    – Codeer
    Jan 3 at 11:03













  • Google for "JPA AttributeConverter".

    – JB Nizet
    Jan 3 at 11:07


















-2















import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;

import com.lue.billingsystem.enums.Status;
import com.lue.billingsystem.enums.Types;

@Entity
@Table(name="product_tab")
public class Product implements Serializable{

private static final long serialVersionUID = 8919320309645697466L;

@Id
@Column(name="prod_id",updatable=false)
@GenericGenerator(name="product_tab_genetator",strategy="increment")
@GeneratedValue(generator="product_tab_genetator")
private Long id;

private String name;

@Enumerated(EnumType.STRING)
@Column(name = "type")
private Types type;

@Column(name = "status")
@Enumerated(EnumType.STRING)
private Status status;

@Column(name = "description", length = 200)
private String description;

@OneToMany(mappedBy="product")
private List<Charge> charges;


@Column(name = "create_date", columnDefinition = "DATETIME")
private Date createDate;

@Column(name = "update_date", columnDefinition = "DATETIME")
private Date updateDate;

//@Version
private Integer version;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Types getType() {
return type;
}
public void setType(Types type) {
this.type = type;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Charge> getCharges() {
return charges;
}
public void setCharges(List<Charge> charges) {
this.charges = charges;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}


}





import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.lue.billingsystem.enums.utils.StatusDeserializer;
import com.lue.billingsystem.exception.BillingException;

@JsonDeserialize(using = StatusDeserializer.class)
public enum Status {
ACTIVE("Active"), INACTIVE("Inactive");

private final String text;

Status(final String text) {
this.text = text;
}

@Override
public String toString() {
return text;
}

public String getText() {
return this.text;
}

public static Status fromText(String text) {
for (Status r : Status.values()) {
if (r.getText().equals(text)) {
System.out.println(r);
return r;
}
}
throw new BillingException("Your Status not valied: "+text +" ", HttpStatus.BAD_REQUEST, 400);
}

}


import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.lue.billingsystem.enums.Status;

public class StatusDeserializer extends JsonDeserializer<Status> {

@Override
public Status deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {

ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);

if (node == null) {
return null;
}

String text = node.textValue(); // gives "A" from the request

if (text == null) {
return null;
}
//System.out.println(Status.fromText(text) + "---------------");
return Status.fromText(text);
}

}


How to enum mapping with jpa Spring boot why not save enum value in DB in DB saving enum key when i saving product in databse not save status like Active it always save ACTIVE










share|improve this question




















  • 2





    Repeating your question four times to get around the 'too little text' pop up, isn't making your question any clearer. Please instead elaborate on your problem and give a description.

    – Codeer
    Jan 3 at 11:03













  • Google for "JPA AttributeConverter".

    – JB Nizet
    Jan 3 at 11:07














-2












-2








-2








import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;

import com.lue.billingsystem.enums.Status;
import com.lue.billingsystem.enums.Types;

@Entity
@Table(name="product_tab")
public class Product implements Serializable{

private static final long serialVersionUID = 8919320309645697466L;

@Id
@Column(name="prod_id",updatable=false)
@GenericGenerator(name="product_tab_genetator",strategy="increment")
@GeneratedValue(generator="product_tab_genetator")
private Long id;

private String name;

@Enumerated(EnumType.STRING)
@Column(name = "type")
private Types type;

@Column(name = "status")
@Enumerated(EnumType.STRING)
private Status status;

@Column(name = "description", length = 200)
private String description;

@OneToMany(mappedBy="product")
private List<Charge> charges;


@Column(name = "create_date", columnDefinition = "DATETIME")
private Date createDate;

@Column(name = "update_date", columnDefinition = "DATETIME")
private Date updateDate;

//@Version
private Integer version;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Types getType() {
return type;
}
public void setType(Types type) {
this.type = type;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Charge> getCharges() {
return charges;
}
public void setCharges(List<Charge> charges) {
this.charges = charges;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}


}





import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.lue.billingsystem.enums.utils.StatusDeserializer;
import com.lue.billingsystem.exception.BillingException;

@JsonDeserialize(using = StatusDeserializer.class)
public enum Status {
ACTIVE("Active"), INACTIVE("Inactive");

private final String text;

Status(final String text) {
this.text = text;
}

@Override
public String toString() {
return text;
}

public String getText() {
return this.text;
}

public static Status fromText(String text) {
for (Status r : Status.values()) {
if (r.getText().equals(text)) {
System.out.println(r);
return r;
}
}
throw new BillingException("Your Status not valied: "+text +" ", HttpStatus.BAD_REQUEST, 400);
}

}


import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.lue.billingsystem.enums.Status;

public class StatusDeserializer extends JsonDeserializer<Status> {

@Override
public Status deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {

ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);

if (node == null) {
return null;
}

String text = node.textValue(); // gives "A" from the request

if (text == null) {
return null;
}
//System.out.println(Status.fromText(text) + "---------------");
return Status.fromText(text);
}

}


How to enum mapping with jpa Spring boot why not save enum value in DB in DB saving enum key when i saving product in databse not save status like Active it always save ACTIVE










share|improve this question
















import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.GenericGenerator;

import com.lue.billingsystem.enums.Status;
import com.lue.billingsystem.enums.Types;

@Entity
@Table(name="product_tab")
public class Product implements Serializable{

private static final long serialVersionUID = 8919320309645697466L;

@Id
@Column(name="prod_id",updatable=false)
@GenericGenerator(name="product_tab_genetator",strategy="increment")
@GeneratedValue(generator="product_tab_genetator")
private Long id;

private String name;

@Enumerated(EnumType.STRING)
@Column(name = "type")
private Types type;

@Column(name = "status")
@Enumerated(EnumType.STRING)
private Status status;

@Column(name = "description", length = 200)
private String description;

@OneToMany(mappedBy="product")
private List<Charge> charges;


@Column(name = "create_date", columnDefinition = "DATETIME")
private Date createDate;

@Column(name = "update_date", columnDefinition = "DATETIME")
private Date updateDate;

//@Version
private Integer version;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Types getType() {
return type;
}
public void setType(Types type) {
this.type = type;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Charge> getCharges() {
return charges;
}
public void setCharges(List<Charge> charges) {
this.charges = charges;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}


}





import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.lue.billingsystem.enums.utils.StatusDeserializer;
import com.lue.billingsystem.exception.BillingException;

@JsonDeserialize(using = StatusDeserializer.class)
public enum Status {
ACTIVE("Active"), INACTIVE("Inactive");

private final String text;

Status(final String text) {
this.text = text;
}

@Override
public String toString() {
return text;
}

public String getText() {
return this.text;
}

public static Status fromText(String text) {
for (Status r : Status.values()) {
if (r.getText().equals(text)) {
System.out.println(r);
return r;
}
}
throw new BillingException("Your Status not valied: "+text +" ", HttpStatus.BAD_REQUEST, 400);
}

}


import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.lue.billingsystem.enums.Status;

public class StatusDeserializer extends JsonDeserializer<Status> {

@Override
public Status deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {

ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);

if (node == null) {
return null;
}

String text = node.textValue(); // gives "A" from the request

if (text == null) {
return null;
}
//System.out.println(Status.fromText(text) + "---------------");
return Status.fromText(text);
}

}


How to enum mapping with jpa Spring boot why not save enum value in DB in DB saving enum key when i saving product in databse not save status like Active it always save ACTIVE







java spring-boot spring-data-jpa






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 11:28









Tim Diekmann

3,41791937




3,41791937










asked Jan 3 at 10:58









kaushal kumarkaushal kumar

61




61








  • 2





    Repeating your question four times to get around the 'too little text' pop up, isn't making your question any clearer. Please instead elaborate on your problem and give a description.

    – Codeer
    Jan 3 at 11:03













  • Google for "JPA AttributeConverter".

    – JB Nizet
    Jan 3 at 11:07














  • 2





    Repeating your question four times to get around the 'too little text' pop up, isn't making your question any clearer. Please instead elaborate on your problem and give a description.

    – Codeer
    Jan 3 at 11:03













  • Google for "JPA AttributeConverter".

    – JB Nizet
    Jan 3 at 11:07








2




2





Repeating your question four times to get around the 'too little text' pop up, isn't making your question any clearer. Please instead elaborate on your problem and give a description.

– Codeer
Jan 3 at 11:03







Repeating your question four times to get around the 'too little text' pop up, isn't making your question any clearer. Please instead elaborate on your problem and give a description.

– Codeer
Jan 3 at 11:03















Google for "JPA AttributeConverter".

– JB Nizet
Jan 3 at 11:07





Google for "JPA AttributeConverter".

– JB Nizet
Jan 3 at 11:07












1 Answer
1






active

oldest

votes


















-1














You just need to pay attention to the enum values when the table is being created.
What are the enum values in the table e.g. in status column, are the values defined as 'Active', 'Inactive' or 'ACTIVE', 'INACTIVE'. That's what will determine the value saved.



If the enum values are defined as 'ACTIVE', 'INACTIVE', if you insert 'active' as the value for status, it will change to 'ACTIVE' inside the database because it inserts based on the pre defined enum values.






share|improve this answer
























  • thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

    – kaushal kumar
    Jan 4 at 5:12













  • I mean the enum definition in your database tables, not in your code.

    – Olantobi
    Jan 4 at 6:04











  • stackoverflow.com/questions/7766791/…

    – kaushal kumar
    Jan 8 at 10:28














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020974%2fhow-to-enum-mapping-with-jpa-spring-boot-why-not-save-enum-value-in-db-in-db-sav%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














You just need to pay attention to the enum values when the table is being created.
What are the enum values in the table e.g. in status column, are the values defined as 'Active', 'Inactive' or 'ACTIVE', 'INACTIVE'. That's what will determine the value saved.



If the enum values are defined as 'ACTIVE', 'INACTIVE', if you insert 'active' as the value for status, it will change to 'ACTIVE' inside the database because it inserts based on the pre defined enum values.






share|improve this answer
























  • thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

    – kaushal kumar
    Jan 4 at 5:12













  • I mean the enum definition in your database tables, not in your code.

    – Olantobi
    Jan 4 at 6:04











  • stackoverflow.com/questions/7766791/…

    – kaushal kumar
    Jan 8 at 10:28


















-1














You just need to pay attention to the enum values when the table is being created.
What are the enum values in the table e.g. in status column, are the values defined as 'Active', 'Inactive' or 'ACTIVE', 'INACTIVE'. That's what will determine the value saved.



If the enum values are defined as 'ACTIVE', 'INACTIVE', if you insert 'active' as the value for status, it will change to 'ACTIVE' inside the database because it inserts based on the pre defined enum values.






share|improve this answer
























  • thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

    – kaushal kumar
    Jan 4 at 5:12













  • I mean the enum definition in your database tables, not in your code.

    – Olantobi
    Jan 4 at 6:04











  • stackoverflow.com/questions/7766791/…

    – kaushal kumar
    Jan 8 at 10:28
















-1












-1








-1







You just need to pay attention to the enum values when the table is being created.
What are the enum values in the table e.g. in status column, are the values defined as 'Active', 'Inactive' or 'ACTIVE', 'INACTIVE'. That's what will determine the value saved.



If the enum values are defined as 'ACTIVE', 'INACTIVE', if you insert 'active' as the value for status, it will change to 'ACTIVE' inside the database because it inserts based on the pre defined enum values.






share|improve this answer













You just need to pay attention to the enum values when the table is being created.
What are the enum values in the table e.g. in status column, are the values defined as 'Active', 'Inactive' or 'ACTIVE', 'INACTIVE'. That's what will determine the value saved.



If the enum values are defined as 'ACTIVE', 'INACTIVE', if you insert 'active' as the value for status, it will change to 'ACTIVE' inside the database because it inserts based on the pre defined enum values.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 13:51









OlantobiOlantobi

6141714




6141714













  • thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

    – kaushal kumar
    Jan 4 at 5:12













  • I mean the enum definition in your database tables, not in your code.

    – Olantobi
    Jan 4 at 6:04











  • stackoverflow.com/questions/7766791/…

    – kaushal kumar
    Jan 8 at 10:28





















  • thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

    – kaushal kumar
    Jan 4 at 5:12













  • I mean the enum definition in your database tables, not in your code.

    – Olantobi
    Jan 4 at 6:04











  • stackoverflow.com/questions/7766791/…

    – kaushal kumar
    Jan 8 at 10:28



















thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

– kaushal kumar
Jan 4 at 5:12







thanks for answer , but in i have some different enum like public enum AccountType { RESIDENTIAL_ACCOUNT("Residential account"), BUSINESS_ACCOUNT("Business account"), SUNDRY_ACCOUNT("Sundry account"); } How to write this type enum please help me

– kaushal kumar
Jan 4 at 5:12















I mean the enum definition in your database tables, not in your code.

– Olantobi
Jan 4 at 6:04





I mean the enum definition in your database tables, not in your code.

– Olantobi
Jan 4 at 6:04













stackoverflow.com/questions/7766791/…

– kaushal kumar
Jan 8 at 10:28







stackoverflow.com/questions/7766791/…

– kaushal kumar
Jan 8 at 10:28






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020974%2fhow-to-enum-mapping-with-jpa-spring-boot-why-not-save-enum-value-in-db-in-db-sav%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith