Configure native sleep id generator in spring context

I use Spring, and Hibernate and I recently created a custom Id generator. Right now, on my Java domain object, I:

@GenericGenerator(name="...", strategy="com.acme.MyIdGenerator", ...) 

Can I create / configure com.acme.MyIdGenerator in my Spring context and somehow use Hibernate instead of Hibernate instance of it?

+4
source share
1 answer

If you are just trying to isolate the generator from the user class (or classes), you can define the generator in the package-info.java class. See this example in the test suite .

But if you really want to match it in XML, you will have to map this particular entity as hbm.xml ( as shown here ) and add it to the Hibernate configuration in the Spring context.

+2
source

Source: https://habr.com/ru/post/1334650/


All Articles