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

如何集成到hibernate使用? #600

Open
meimosor opened this issue Jul 17, 2024 · 0 comments
Open

如何集成到hibernate使用? #600

meimosor opened this issue Jul 17, 2024 · 0 comments

Comments

@meimosor
Copy link

我再hibernate自定义了一个ID生成器,如何在替换这里的逻辑使CosId的雪花ID生成器生效?

public class YuIdGenerator implements IdentifierGenerator {

    static SnowFlake snowFlake;

    static {
        snowFlake = new SnowFlake(1, 1);
    }

    @Override
    public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
        return snowFlake.nextId();
    }
}
import jakarta.persistence.Id;
/**
* 主键
*/
@Id
@GenericGenerator(name = "yu_id", strategy = "com.xxx.common.jpa.xxx.YuIdGenerator")
@GeneratedValue(generator = "yu_id")
private Long id;
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

1 participant