I am persisting entity to mysql database. my requirement is to store id as BR01 , BR02 ,... etc. instead of storing as 1,2,.. etc.
how can i store id as BR01,BR02,.. etc?
I know sequence is not supported in mysql database.
my entity class is as follows :
package com.kabira.hrm.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
@Entity
@Table(name="branch")
public class Branch
{
private Long id;
private String country;
private String state;
private String city;
private String address;
private String phoneNumber;
@Id
@GeneratedValue
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getCountry()
{
return country;
}
public void setCountry(String country)
{
this.country = country;
}
public String getState()
{
return state;
}
public void setState(String state)
{
this.state = state;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address = address;
}
public String getPhoneNumber()
{
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber)
{
this.phoneNumber = phoneNumber;
}
@Override
public String toString()
{
return "Branch [id=" + id + "]";
}
}