[JAVA] How to write in Model class when you want to save binary data in DB with PlayFramework

In PlayFramework, by creating a Model class (class with @Entity annotation), SQl of create statement is automatically issued, and there is a function to create a table according to the contents defined in the class. At that time, I didn't know how to write the column to save the binary data, so it took time, so I will record it.

The way to write it is as follows.

@Lob public byte[] paramBlob;

The following is a sample implementation.


package models.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import play.db.ebean.Model;

public class TbParam extends Model {

	public Integer id;
	public byte[] paramBlob;

	public TbWorkParam(){


With the above writing method, in the mysql environment, the column paramBlob is created as a longblob type.

Recommended Posts

How to write in Model class when you want to save binary data in DB with PlayFramework
When you want to explicitly write OR or AND with ransack
How to write when you want to keep line breaks and output while avoiding XSS in Rails
How to write when you want to handle "array of C language strings" like argv [] in Ruby-FFI
When you want to bind InputStream in JDBI3
How to store data simultaneously in a model associated with a nested form (Rails 6.0.0)
When you want to dynamically replace Annotation in Java8
Code to use when you want to process Json with only standard library in Java
How to use the same Mapper class in multiple data sources with Spring Boot + MyBatis
How to specify db when creating an app with rails
When you want to implement Java library testing in Spock with multi-module in Gradle in Android Studio 3
Mapping to a class with a value object in How to MyBatis
docker-compose.yml when you want to keep mysql running with docker
lombok.config when you want to pass @Qualifier to @RequiredArgsConstructor with lombok
[Spring Dtata JPA] How to deal with the problem that DB change cannot be detected when you want to process API synchronously with a single thread in Spring Boot.
If you want to include the parent class in Lombok's @builder
When you want to ZIP download the image data saved locally
How to rename a model with foreign key constraints in Rails
How to write when installing Amazon Corretto 8 on CentOS 8 with Ansible.
[Rails] I want to add data to Params when transitioning with link_to
How to write the view when Vue is introduced in Rails?
[Rails] How to write in Japanese
The first thing to do when you want to be happy with Heroku on GitHub with Eclipse in Java
Summary of means when you want to communicate with HTTP on Android
How to get date data in Ruby
To write Response data directly in Spring
How to delete data with foreign key
How to overwrite Firebase data in Swift
How to fix a crash when deleting Realm data in Swift UI List
How to output jar with main class specified by gradle in Intellij IDEA
When you want to notify an error somewhere when using graphql-spring-boot in Spring Boot
When defining a class, write formatTo as well as toString (how to use Formattable)
Code used when you want to process Json with only the standard library in Java (improved version) gson unnecessary
How to solve when you cannot connect to DB with a new container because the port is assigned to the existing docker container
How to get keycloak credentials in interceptor class
[Rails] How to write when making a subquery
How to save to multiple tables with one input
When you get lost in the class name
JUnit 5: How to write test cases in enum
How to get Class from Element in Java
A note when you want Tuple in Java
When you want to use the method outside
How to conditionally add html.erb class in Rails
[Swift] Use nonzeroBitCount when you want popcnt in Swift
How to write test code with Basic authentication
[Java] How to substitute Model Mapper in Jackson
How to create member variables with JPA Model
What to do when IllegalStateException occurs in PlayFramework
How to log in automatically when Ubuntu restarts
How to write Java String # getBytes in Kotlin?
Notes on how to write comments in English
[Ruby] When you want to replace multiple characters
How to delete the tweet associated with the user when you delete it at the same time
If you use SQLite with VSCode, use the extension (how to see the binary file of sqlite3)
[rails] After option useful when you want to change the order of DB columns
How to get the class name of the argument of LoggerFactory.getLogger when using SLF4J in Java
You don't have to write for twice when you make a right triangle in Java
How to save a file with the specified extension under the directory specified in Java to the list
Summary of how to use the proxy set in IE when connecting with Java