#1211: HibernateProxySerializer.kt

projectforge-business/src/main/kotlin/org/projectforge/framework/json/HibernateProxySerializer.kt JSON Serializer, projectforge-business/src/main/kotlin/org/projectforge/framework/json/HibernateProxySerializer.kt 48 lines · 23 code · 22 comments · 3 blank
Jackson StdSerializer for Hibernate's AbstractLazyInitializer (lazy-loading proxies). Serializes lazy proxies to a compact JSON object containing only the entity ID: {"id":"123"}. Prevents LazyInitializationException during JSON serialization by never triggering proxy initialization.

Architecture

Serialization Logic

value == null  → writeNull()
value != null  → {"id": "${value.identifier}" (or null if identifier is null)}

This serializer is registered globally on the Jackson ObjectMapper in JsonUtils.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
7c79f1922 Copyright of source header -> 2020.
74c0658ca HibernateProxySerializer.
05244ff19 CopyRight of all Kotlin file-header updated or created.
bd3a3e824 Module projectforge-jax-rs renamed to projectforge-rest.
7a4952a79 Fixed Calendar Serializer.
00c8b33dc Gson removed. WIP: Jersey -> Spring Boot rest....
232fc324c WIP: team calendar...

#1211: HibernateProxySerializer.kt

JSON Serializer, projectforge-business/src/main/kotlin/org/projectforge/framework/json/HibernateProxySerializer.kt
Jackson StdSerializer for Hibernate's AbstractLazyInitializer (lazy-loading proxies). Serializes lazy proxies to a compact JSON object containing only the entity ID: {"id":"123"}. Prevents LazyInitializationException during JSON serialization by never triggering proxy initialization.

Architecture

Serialization Logic

value == null  → writeNull()
value != null  → {"id": "${value.identifier}" (or null if identifier is null)}

This serializer is registered globally on the Jackson ObjectMapper in JsonUtils.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
7c79f1922 Copyright of source header -> 2020.
74c0658ca HibernateProxySerializer.
05244ff19 CopyRight of all Kotlin file-header updated or created.
bd3a3e824 Module projectforge-jax-rs renamed to projectforge-rest.
7a4952a79 Fixed Calendar Serializer.
00c8b33dc Gson removed. WIP: Jersey -> Spring Boot rest....
232fc324c WIP: team calendar...