Home » Java » Enterprise Java

Enterprise Java

How to map JSON collections using JPA and Hibernate

Introduction The open-source hibernate-types project allows you to map Java objects or Jackson JsonNode as JPA entity properties. Recently, thanks to our awesome contributors, we added support for type-safe collections to be persisted as JSON as well. In this article, you are going to see how to achieve this goal. Maven dependency First of all, you need to set up ...

Read More »

Neo4j: Cypher – Property values can only be of primitive types or arrays thereof

I ran into an interesting Cypher error message earlier this week while trying to create an array property on a node which I thought I’d share. This was the Cypher query I wrote: CREATE (:Person {id: [1, "mark", 2.0]}) which results in this error: Neo.ClientError.Statement.TypeError Property values can only be of primitive types or arrays thereof. We actually are storing ...

Read More »

Using JAX-RS exceptions for status codes

java-interview-questions-answers

One way to send specific HTTP (error) status codes from a JAX-RS resource is to use the javax.ws.rs.core.Response class with its Builder Pattern-like API. If you want to specify the return type according to the response body, you can still do so and send a different status on errors by throwing a WebApplicationException. @Path("test") public class TestResource { @GET public ...

Read More »

JPA persistence.xml SQL script definitions

java-interview-questions-answers

You can define and link to SQL scripts in a JPA persistence context definition that will be executed at runtime. There are standardized properties to define scripts how to create the schema, bulk-load data and drop the schema, respectively: <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="prod" transaction-type="JTA"> <properties> <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/> <property name="javax.persistence.schema-generation.create-script-source" value="create-schema.sql" /> <property name="javax.persistence.schema-generation.sql-load-script-source" value="load-data.sql" /> ...

Read More »

Cloud Happiness – How to install new OpenShift Container Platform 3.7 in minutes

This installation needs to have the Red Hat Middleware product streams installed (pre-configured container options) and all the extras like source to image and .Net Core containers.Since the release of the OpenShift Container Platform it has been my desire to provide a simple, fully configured and easy to use installation. Since I last updated this project, OpenShift Container Platform 3.7 ...

Read More »