com.vladmihalcea.hibernate.type.json.JsonBinaryType Java Examples

The following examples show how to use com.vladmihalcea.hibernate.type.json.JsonBinaryType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostgreSQLJsonBinaryTypeProgrammaticConfigurationSupplierTest.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
    objectMapper.setTimeZone(TimeZone.getTimeZone("GMT"));
    SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1, 0, 0, null, null, null));
    simpleModule.addSerializer(new MoneySerializer());
    objectMapper.registerModule(simpleModule);

    JsonBinaryType jsonBinaryType = new JsonBinaryType(objectMapper, Location.class);

    properties.put("hibernate.type_contributors",
        (TypeContributorList) () -> Collections.singletonList(
            (typeContributions, serviceRegistry) ->
                typeContributions.contributeType(
                    jsonBinaryType, "location"
                )
        )
    );
}
 
Example #2
Source File: PostgreSQLJsonBinaryTypeProgrammaticConfigurationTest.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    CustomObjectMapperSupplier customObjectMapperSupplier = new CustomObjectMapperSupplier();
    final JsonBinaryType jsonBinaryType = new JsonBinaryType(customObjectMapperSupplier.get(), Location.class);

    properties.put( "hibernate.type_contributors", new TypeContributorList() {
        @Override
        public List<TypeContributor> getTypeContributors() {
            List<TypeContributor> typeContributors = new ArrayList<TypeContributor>();
            typeContributors.add(new TypeContributor() {
                @Override
                public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
                    typeContributions.contributeType(
                        jsonBinaryType, "location"
                    );
                }
            });
            return typeContributors;
        }
    });
}
 
Example #3
Source File: PostgreSQLJsonBinaryTypeProgrammaticConfigurationTest.java    From hibernate-types with Apache License 2.0 5 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    CustomObjectMapperSupplier customObjectMapperSupplier = new CustomObjectMapperSupplier();
    JsonBinaryType jsonBinaryType = new JsonBinaryType(customObjectMapperSupplier.get(), Location.class);

    properties.put("hibernate.type_contributors",
        (TypeContributorList) () -> Collections.singletonList(
            (typeContributions, serviceRegistry) ->
                typeContributions.contributeType(
                    jsonBinaryType, "location"
                )
        )
    );
}