-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,14 @@ | |
|
||
package org.projectforge.business.fibu.orderbooksnapshots | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import jakarta.persistence.* | ||
import org.projectforge.framework.json.JsonUtils | ||
import java.time.LocalDate | ||
import java.util.Date | ||
import java.util.* | ||
|
||
/** | ||
* SELECT date, created, incremental_based_on, octet_length(serialized_orderbook) AS byte_count FROM t_fibu_orderbook_snapshots; | ||
* SELECT date, created, incremental_based_on, octet_length(serialized_orderbook) AS byte_count, size FROM t_fibu_orderbook_snapshots; | ||
* @author Kai Reinhard ([email protected]) | ||
*/ | ||
@Entity | ||
|
@@ -37,9 +39,18 @@ import java.util.Date | |
uniqueConstraints = [UniqueConstraint(columnNames = ["date"])], | ||
) | ||
@NamedQueries( | ||
NamedQuery(name = OrderbookSnapshotDO.FIND_META_BY_DATE, query = "select date as date,incrementalBasedOn as incrementalBasedOn from OrderbookSnapshotDO where date=:date"), | ||
NamedQuery(name = OrderbookSnapshotDO.SELECT_ALL_METAS, query = "select date as date,incrementalBasedOn as incrementalBasedOn from OrderbookSnapshotDO order by date desc"), | ||
NamedQuery(name = OrderbookSnapshotDO.SELECT_ALL_FULLBACKUP_METAS, query = "select date as date,incrementalBasedOn as incrementalBasedOn from OrderbookSnapshotDO where incrementalBasedOn is null order by date desc"), | ||
NamedQuery( | ||
name = OrderbookSnapshotDO.FIND_META_BY_DATE, | ||
query = "select date as date,incrementalBasedOn as incrementalBasedOn,size as size from OrderbookSnapshotDO where date=:date" | ||
), | ||
NamedQuery( | ||
name = OrderbookSnapshotDO.SELECT_ALL_METAS, | ||
query = "select date as date,incrementalBasedOn as incrementalBasedOn,size as size from OrderbookSnapshotDO order by date desc" | ||
), | ||
NamedQuery( | ||
name = OrderbookSnapshotDO.SELECT_ALL_FULLBACKUP_METAS, | ||
query = "select date as date,incrementalBasedOn as incrementalBasedOn,size as size from OrderbookSnapshotDO where incrementalBasedOn is null order by date desc" | ||
), | ||
) | ||
internal class OrderbookSnapshotDO { | ||
@get:Id | ||
|
@@ -55,6 +66,7 @@ internal class OrderbookSnapshotDO { | |
*/ | ||
@get:Column(name = "serialized_orderbook", columnDefinition = "BLOB") | ||
@get:Basic(fetch = FetchType.LAZY) // Lazy isn't reliable for byte arrays. | ||
@JsonIgnore | ||
var serializedOrderBook: ByteArray? = null | ||
|
||
/** | ||
|
@@ -63,10 +75,17 @@ internal class OrderbookSnapshotDO { | |
@get:Column(name = "incremental_based_on") | ||
var incrementalBasedOn: LocalDate? = null | ||
|
||
@get:Column | ||
var size: Int? = null | ||
|
||
@get:Transient | ||
val incremental: Boolean | ||
get() = incrementalBasedOn != null | ||
|
||
override fun toString(): String { | ||
return JsonUtils.toJson(this) | ||
} | ||
|
||
companion object { | ||
internal const val FIND_META_BY_DATE = "OrderSnapshotsDO_FindMetaByDate" | ||
internal const val SELECT_ALL_METAS = "OrderSnapshotsDO_SelectAllMetas" | ||
|
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