{"id":125146,"date":"2024-07-31T11:17:05","date_gmt":"2024-07-31T08:17:05","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=125146"},"modified":"2024-07-31T11:17:08","modified_gmt":"2024-07-31T08:17:08","slug":"integrating-java-enums-with-jpa-and-postgresql-enums","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html","title":{"rendered":"Integrating Java Enums with JPA and PostgreSQL Enums"},"content":{"rendered":"<p><a href=\"https:\/\/www.javacodegeeks.com\/2018\/12\/map-postgresql-jpa-entity-hibernate.html\" target=\"_blank\" rel=\"noreferrer noopener\">Enums<\/a> are a powerful feature in Java, allowing us to define a fixed set of constants. When using JPA (Java Persistence API) with PostgreSQL, we might want to store these enums in a PostgreSQL enum type. This article demonstrates how to integrate Java enums with JPA and PostgreSQL enums.<\/p>\n<h2 class=\"wp-block-heading\">1. Setting Up the Project<\/h2>\n<p>First, create a new Maven project and include the necessary dependencies in the <code>pom.xml<\/code> file. These dependencies include Hibernate Core for JPA implementation, PostgreSQL driver for database connection, and Hypersistence Utils library to simplify working with PostgreSQL enums.<\/p>\n<pre class=\"brush:xml\">\n    &lt;dependencies&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.hibernate&lt;\/groupId&gt;\n            &lt;artifactId&gt;hibernate-core&lt;\/artifactId&gt;\n            &lt;version&gt;5.6.15.Final&lt;\/version&gt;\n        &lt;\/dependency&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.postgresql&lt;\/groupId&gt;\n            &lt;artifactId&gt;postgresql&lt;\/artifactId&gt;\n            &lt;version&gt;42.4.1&lt;\/version&gt;\n        &lt;\/dependency&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;io.hypersistence&lt;\/groupId&gt;\n            &lt;artifactId&gt;hypersistence-utils-hibernate-55&lt;\/artifactId&gt;\n            &lt;version&gt;3.8.2&lt;\/version&gt;\n        &lt;\/dependency&gt;\n    &lt;\/dependencies&gt;\n<\/pre>\n<p>In this setup, the Hibernate Core dependency provides the JPA implementation, the PostgreSQL dependency is the JDBC driver for PostgreSQL, and Hypersistence Utils extends Hibernate with additional types and utilities that simplify handling PostgreSQL-specific features, like enums.<\/p>\n<h2 class=\"wp-block-heading\">2. Define the Enum<\/h2>\n<p>Next, we define the Java enum, which will be used to represent the status of a user in our application.<\/p>\n<pre class=\"brush:java\">\npublic enum Status {\n    ACTIVE,\n    INACTIVE,\n    SUSPENDED;\n}\n<\/pre>\n<p>This <code>Status<\/code> enum contains three possible values: <code>ACTIVE<\/code>, <code>INACTIVE<\/code>, and <code>SUSPENDED<\/code>. This will correspond directly to the PostgreSQL enum type we will create in the database.<\/p>\n<h2 class=\"wp-block-heading\">3. Create the PostgreSQL Enum Type<\/h2>\n<p>Before we can use the Java enum with PostgreSQL, we need to create the corresponding enum type in our PostgreSQL database. Connect to your PostgreSQL database and execute the following SQL command:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:sql\">\nCREATE TYPE status AS ENUM ('ACTIVE', 'INACTIVE', 'SUSPENDED');\n<\/pre>\n<p>This SQL command creates a new enum type named <code>status<\/code> in PostgreSQL with the same values as our Java enum. This ensures consistency between our database schema and our application logic.<\/p>\n<h3 class=\"wp-block-heading\">3.1 Create the Table Using the Enum Type<\/h3>\n<p>Next, create a table that uses the <code>status<\/code> enum type.<\/p>\n<pre class=\"brush:sql\">\nCREATE TABLE users (\n    id SERIAL PRIMARY KEY,\n    name VARCHAR(100) NOT NULL,\n    status status NOT NULL\n);\n<\/pre>\n<h2 class=\"wp-block-heading\">4. Configure the JPA Entity with Hypersistence Utils<\/h2>\n<p>Now, we configure our JPA entity to use the <code>Status<\/code> enum. We will leverage the <a href=\"https:\/\/github.com\/vladmihalcea\/hypersistence-utils\" target=\"_blank\" rel=\"noreferrer noopener\">Hypersistence Utils<\/a> library to map the PostgreSQL enum type to our Java enum.<\/p>\n<pre class=\"brush:java\">\n@Entity\n@TypeDef(\n    name = \"pgsql_enum\",\n    typeClass = PostgreSQLEnumType.class\n)\npublic class Users implements Serializable {\n    \n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    private String name;\n\n    @Enumerated(EnumType.STRING)\n    @Column(columnDefinition = \"status\")\n    @Type(type = \"pgsql_enum\")\n    private Status status;\n\n    public Long getId() {\n        return id;\n    }\n\n    public void setId(Long id) {\n        this.id = id;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public Status getStatus() {\n        return status;\n    }\n\n    public void setStatus(Status status) {\n        this.status = status;\n    }\n    \n}\n\n<\/pre>\n<p>In this configuration, the <code>@TypeDef<\/code> annotation registers the <code>PostgreSQLEnumType<\/code> under the name <code>pgsql_enum<\/code>. The <code>@Enumerated(EnumType.STRING)<\/code> annotation specifies that the enum should be stored as a string in the database. The <code>@Type(type = \"pgsql_enum\")<\/code> annotation tells Hibernate to use the <code>PostgreSQLEnumType<\/code> for the <code>status<\/code> field, ensuring the correct handling of the PostgreSQL enum type.<\/p>\n<h2 class=\"wp-block-heading\">5. Write the Main Application<\/h2>\n<p>Finally, write the main application to test the integration. This application will create a new user, persist it to the database, and then retrieve it to verify the integration.<\/p>\n<pre class=\"brush:java\">\npublic class PostgresqlEnumTypeExample {\n\n    public static void main(String[] args) {\n        \/\/ Create an EntityManagerFactory\n        EntityManagerFactory emf = Persistence.createEntityManagerFactory(\"postgresqlEnumTypeExamplePU\");\n\n        \/\/ Create an EntityManager\n        EntityManager em = emf.createEntityManager();\n\n        \/\/ Start a transaction\n        em.getTransaction().begin();\n\n        \/\/ Create a new User\n        Users user = new Users();\n        user.setName(\"Benjamin Fish\");\n        user.setStatus(Status.ACTIVE);\n\n        \/\/ Persist the User\n        em.persist(user);\n\n        \/\/ Commit the transaction\n        em.getTransaction().commit();\n\n        \/\/ Close the EntityManager\n        em.close();\n\n        \/\/ Open a new EntityManager to retrieve the User\n        em = emf.createEntityManager();\n\n        Users retrievedUser = em.find(Users.class, user.getId());\n        System.out.println(\"Retrieved User: \" + retrievedUser.getName() + \", Status: \" + retrievedUser.getStatus());\n\n        \/\/ Close the EntityManager\n        em.close();\n\n        \/\/ Close the EntityManagerFactory\n        emf.close();\n    }\n}\n\n<\/pre>\n<p>When you run the main application, it should output the following:<\/p>\n<pre class=\"brush:plain\">\nHibernate: insert into Users (name, status) values (?, ?)\nHibernate: select users0_.id as id1_0_0_, users0_.name as name2_0_0_, users0_.status as status3_0_0_ from Users users0_ where users0_.id=?\nRetrieved User: Benjamin Fish, Status: ACTIVE\n<\/pre>\n<p>The application prints the retrieved user&#8217;s details to the console, confirming that the user has been successfully persisted and retrieved.<\/p>\n<h2 class=\"wp-block-heading\">6. Conclusion<\/h2>\n<p>In this article, we explored how to integrate Java enums with JPA and PostgreSQL enums using the Hypersistence Utils library. We began by setting up a Maven project and including the necessary dependencies. We then defined a Java enum, created the corresponding PostgreSQL enum type and configured our JPA entity with the <code>@JdbcType<\/code> and <code>@Type<\/code> annotations from Hypersistence Utils. Finally, we demonstrated how to persist and retrieve data using a main application. <\/p>\n<p>This setup allows us to leverage PostgreSQL&#8217;s enum types in a type-safe manner within our Java application, ensuring consistency and type safety across our application and database layers.<\/p>\n<h2 class=\"wp-block-heading\">7. Download the Source Code<\/h2>\n<p>This article explores how to work with Java enums, JPA, and PostgreSQL.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/07\/postgresqlEnumTypeExample.zip\"><strong>java enums jpa postgresql<\/strong><\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Enums are a powerful feature in Java, allowing us to define a fixed set of constants. When using JPA (Java Persistence API) with PostgreSQL, we might want to store these enums in a PostgreSQL enum type. This article demonstrates how to integrate Java enums with JPA and PostgreSQL enums. 1. Setting Up the Project First, &hellip;<\/p>\n","protected":false},"author":128888,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[437,33,657],"class_list":["post-125146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-enums","tag-jpa","tag-postgresql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Integrating Java Enums with JPA and PostgreSQL Enums - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Learn how to map Java enums to PostgreSQL enums in JPA applications with full code examples and detailed explanations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Integrating Java Enums with JPA and PostgreSQL Enums - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Learn how to map Java enums to PostgreSQL enums in JPA applications with full code examples and detailed explanations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/web.facebook.com\/omos.aziegbe\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-31T08:17:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-31T08:17:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Omozegie Aziegbe\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OAziegbe\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Omozegie Aziegbe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html\"},\"author\":{\"name\":\"Omozegie Aziegbe\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7d3eac6e45542536e961129ae0fb453e\"},\"headline\":\"Integrating Java Enums with JPA and PostgreSQL Enums\",\"datePublished\":\"2024-07-31T08:17:05+00:00\",\"dateModified\":\"2024-07-31T08:17:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html\"},\"wordCount\":538,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"Enums\",\"JPA\",\"PostgreSQL\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html\",\"name\":\"Integrating Java Enums with JPA and PostgreSQL Enums - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2024-07-31T08:17:05+00:00\",\"dateModified\":\"2024-07-31T08:17:08+00:00\",\"description\":\"Learn how to map Java enums to PostgreSQL enums in JPA applications with full code examples and detailed explanations.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/integrating-java-enums-with-jpa-and-postgresql-enums.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Integrating Java Enums with JPA and PostgreSQL Enums\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7d3eac6e45542536e961129ae0fb453e\",\"name\":\"Omozegie Aziegbe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"caption\":\"Omozegie Aziegbe\"},\"description\":\"Omos Aziegbe is a technical writer and web\\\/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.\",\"sameAs\":[\"https:\\\/\\\/web.facebook.com\\\/omos.aziegbe\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/omosaziegbe\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/OAziegbe\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/omozegie-aziegbe\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Integrating Java Enums with JPA and PostgreSQL Enums - Java Code Geeks","description":"Learn how to map Java enums to PostgreSQL enums in JPA applications with full code examples and detailed explanations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html","og_locale":"en_US","og_type":"article","og_title":"Integrating Java Enums with JPA and PostgreSQL Enums - Java Code Geeks","og_description":"Learn how to map Java enums to PostgreSQL enums in JPA applications with full code examples and detailed explanations.","og_url":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/web.facebook.com\/omos.aziegbe","article_published_time":"2024-07-31T08:17:05+00:00","article_modified_time":"2024-07-31T08:17:08+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Omozegie Aziegbe","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OAziegbe","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Omozegie Aziegbe","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html"},"author":{"name":"Omozegie Aziegbe","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7d3eac6e45542536e961129ae0fb453e"},"headline":"Integrating Java Enums with JPA and PostgreSQL Enums","datePublished":"2024-07-31T08:17:05+00:00","dateModified":"2024-07-31T08:17:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html"},"wordCount":538,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["Enums","JPA","PostgreSQL"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html","url":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html","name":"Integrating Java Enums with JPA and PostgreSQL Enums - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2024-07-31T08:17:05+00:00","dateModified":"2024-07-31T08:17:08+00:00","description":"Learn how to map Java enums to PostgreSQL enums in JPA applications with full code examples and detailed explanations.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/integrating-java-enums-with-jpa-and-postgresql-enums.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Integrating Java Enums with JPA and PostgreSQL Enums"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7d3eac6e45542536e961129ae0fb453e","name":"Omozegie Aziegbe","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","caption":"Omozegie Aziegbe"},"description":"Omos Aziegbe is a technical writer and web\/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.","sameAs":["https:\/\/web.facebook.com\/omos.aziegbe","https:\/\/www.linkedin.com\/in\/omosaziegbe\/","https:\/\/x.com\/https:\/\/twitter.com\/OAziegbe"],"url":"https:\/\/www.javacodegeeks.com\/author\/omozegie-aziegbe"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/125146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/128888"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=125146"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/125146\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=125146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=125146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=125146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}