forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow JSON/XML serialization customization in ORM
- add qualifiers to mark FormatMapper for JSON/XML formatting - use a Quarkus-configured ObjectMapper if Jackson is present and user did not specify a format mapper - use a Quarkus-configured Jsonb if Jsonb is present and user did not specify a format mapper
- Loading branch information
1 parent
1321361
commit b580d5f
Showing
29 changed files
with
764 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/JsonFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.quarkus.hibernate.orm; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
|
||
import org.hibernate.type.format.FormatMapper; | ||
|
||
/** | ||
* CDI qualifier for beans implementing a {@link FormatMapper}. | ||
* <p> | ||
* This mapper will be used by Hibernate ORM for serialization and deserialization of JSON properties. | ||
* <p> | ||
* <strong>Must</strong> be used in a combination with a {@link PersistenceUnitExtension} qualifier to define the persistence | ||
* unit the mapper should be associated with. | ||
*/ | ||
@Target({ TYPE, FIELD, METHOD, PARAMETER }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Qualifier | ||
public @interface JsonFormat { | ||
class Literal extends AnnotationLiteral<JsonFormat> implements JsonFormat { | ||
public static JsonFormat INSTANCE = new Literal(); | ||
|
||
private Literal() { | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/XmlFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.quarkus.hibernate.orm; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
|
||
import org.hibernate.type.format.FormatMapper; | ||
|
||
/** | ||
* CDI qualifier for beans implementing a {@link FormatMapper}. | ||
* <p> | ||
* This mapper will be used by Hibernate ORM for serialization and deserialization of XML properties. | ||
* <p> | ||
* <strong>Must</strong> be used in a combination with a {@link PersistenceUnitExtension} qualifier to define the persistence | ||
* unit the mapper should be associated with. | ||
*/ | ||
@Target({ TYPE, FIELD, METHOD, PARAMETER }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Qualifier | ||
public @interface XmlFormat { | ||
class Literal extends AnnotationLiteral<XmlFormat> implements XmlFormat { | ||
public static XmlFormat INSTANCE = new Literal(); | ||
|
||
private Literal() { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.