-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
SettingsSpyingIdentifierGenerator.java
35 lines (30 loc) · 1.36 KB
/
SettingsSpyingIdentifierGenerator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package io.quarkus.hibernate.orm.config.unsupportedproperties;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.Type;
/**
* This was the only way I found to get our hands on the settings used during metadata building.
* Feel free to use some other solution if you find one.
*/
public class SettingsSpyingIdentifierGenerator implements IdentifierGenerator {
static final List<Map<String, Object>> collectedSettings = new ArrayList<>();
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException {
collectedSettings.add(new HashMap<>(serviceRegistry.getService(ConfigurationService.class).getSettings()));
}
@Override
public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
throw new IllegalStateException("This should not be called");
}
}