36563

What data type does ebean map to BYTEA?

Question:

I have a Play! 2.0.2 application that needs to store some files in the database. we are using Ebean for our ORM. I believe I need a BYTEA column in my database to store the file, but I'm not sure what data type to use in my model.

Should I be using some kind of Blob? Or just a byte[]? Or is there another data type I should be using? Thanks!

Answer1:

To create blob with Ebean you need to use byte array with @Lob annotation

@Lob public byte[] image;

You'll need to convert between File <-> byte array, so maybe it's easier to store files in filesystem? (besides storing files in FS is just cheaper than in DB)

Recommend

  • Bytea data format in R shiny
  • Reverse engineer array dimensions / struct layout from compiler asm output?
  • How to get a list of all blobs in a repository in Git
  • How to get or calculate size of Azure File/Share or Service
  • Selecting a subset of data in ServiceStack.OrmLite
  • Using Nested Table variables / Collections in SQL inside PL/SQL blocks
  • NHibernate manually control fetching
  • Getting NullPointer exception with File.listfiles()
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • Eloquent update method change created_at timestamp
  • Groovy: Unexpected token “:”
  • copying resource to sdcard gives a damaged file in android
  • iOS: Detect app start via notification press
  • Replace value with Factor in r data.table
  • Yii2: Config params vs. const/define
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Ajax Loaded meta Tags
  • How to access EntityManager inside Entity class in EJB3
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Spring Data JPA custom method causing PropertyReferenceException
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • How do you troubleshoot character encoding problems?
  • Why winpcap requires both .lib and .dll to run?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to include full .NET prerequisite for Wix Burn installer
  • KeystoneJS: Relationships in Admin UI not updating
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • How do I configure my settings file to work with unit tests?
  • embed rChart in Markdown
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Is it possible to post an object from jquery to bottle.py?
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app