i am new to hibernate. i was trying to create custom id of type string using hibernate and mysql. can someone help me with how to override generator class?
why is it asking me to implement unimplemented methods in class name
it implements the following sets of code @Override
public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
// TODO Auto-generated method stub
return null;
}
}
also it asks me to remove @Override from generate method
Yes, you can use XML too, but why would you use a deprecated mapping model?
It seems you are using an old Hibernate version. Upgrade to 5.2 and it will work. Or adapt it to the old method signature. It’s very easy. You’ll figure it out.
These are my gradle dependencies
implementation ‘org.springframework.boot:spring-boot-starter-web’
implementation ‘mysql:mysql-connector-java:8.0.15’
implementation ‘org.hibernate:hibernate-core:5.4.1.Final’
implementation ‘org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final’
MySQL does not support sequences, so you could not do that for the PK. Only if thevPK is identity and you use that value to build a secondary column with the String prefix amd the ID value combined.
Better late than never!
Regarding the LongType issue, you can switch to: super.configure(new TypeConfiguration().getBasicTypeRegistry().getRegisteredType(Long.class), params, serviceRegistry);
@vlad your post helped the community so much on SequenceStyleGenerator usage, I’m wondering if you have a plan to have another post for using SequenceStyleGenerator in Hibernate 6, as well as new supports for strong type. I believe it will be super helpful. (Sorry if this is unrelated)