Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
<html>
<head>
<title>Mapping | Ebean</title>
<meta name="layout" content="_layout2/base-mapping.html"/>
</head>
<body>
<h5>Types</h5>
<p style="font-size: 0.83rem;font-weight: bold;">
<a href="/docs/mapping/type/">All types</a>,
<a href="/docs/mapping/type/enum">Enum</a>,
<a href="/docs/mapping/type/uuid">UUID</a>,
<a href="/docs/mapping/type/file">File</a>,
<a href="/docs/mapping/type/boolean">Boolean</a>,
<a href="/docs/mapping/type/time">Date and Time</a>,
<a href="/docs/mapping/type/numeric">Numeric</a>,
<a href="/docs/mapping/type/">Other</a>
</p>
<h5>JPA mapping</h5>
<div class="grid g3">
<div>
<h5><a href="/docs/mapping/jpa/id">@Id</a></h5>
<h5><a href="/docs/mapping/jpa/version">@Version</a></h5>
<h5><a href="/docs/mapping/jpa/mapped-superclass">@MappedSuperclass</a></h5>
</div>
<div>
<h5><a href="/docs/mapping/jpa/one-to-many">@OneToMany</a></h5>
<h5><a href="/docs/mapping/jpa/many-to-one">@ManyToOne</a></h5>
<h5><a href="/docs/mapping/jpa/one-to-one">@OneToOne</a></h5>
<h5><a href="/docs/mapping/jpa/many-to-many">@ManyToMany</a></h5>
</div>
<div>
<h5><a href="/docs/mapping/jpa/lob">@Lob</a></h5>
</div>
</div>
<h5>Ebean mapping extenions</h5>
<div class="grid g3">
<div>
<h5><a href="/docs/mapping/extensions/dbindex">@Index</a></h5>
<h5><a href="/docs/mapping/extensions/dbjson">@DbJson</a></h5>
<h5><a href="/docs/mapping/extensions/dbarray">@DbArray</a></h5>
<h5><a href="/docs/mapping/extensions/dbarray">@DbHstore</a></h5>
<h5><a href="/docs/mapping/extensions/dbcomment">@DbComment</a></h5>
<h5><a href="/docs/mapping/extensions/dbpartition">@DbPartition</a></h5>
</div>
<div>
<h5><a href="/docs/mapping/extensions/when-created">@WhenCreated</a></h5>
<h5><a href="/docs/mapping/extensions/when-modified">@WhenModified</a></h5>
<h5><a href="/docs/mapping/extensions/who-created">@WhoCreated</a></h5>
<h5><a href="/docs/mapping/extensions/who-modified">@WhoModified</a></h5>
</div>
<div>
<h5><a href="/docs/mapping/extensions/view">@View</a></h5>
<h5><a href="/docs/mapping/extensions/soft-delete">@SoftDelete</a></h5>
<h5><a href="/docs/mapping/extensions/encrypted">@Encrypted</a></h5>
<h5><a href="/docs/mapping/extensions/read-audit">@ReadAudit</a></h5>
<h5><a href="/docs/mapping/extensions/history">@History</a></h5>
<h5><a href="/docs/mapping/extensions/formula">@Formula</a></h5>
<h5><a href="/docs/mapping/extensions/change-log">@ChangeLog</a></h5>
</div>
</div>
<h2 id="constructors"><a href="constructors">Constructors</a></h2>
<p>
Unlike JPA Ebean does <b>NOT</b> require a default constructor. You are free to create
entity beans that have a constructor with arguments.
</p>
<h2 id="naming-convention"><a href="naming-convention">Naming convention</a></h2>
<p>
Ebean uses a Naming convention API. This is relatively important as it typically
means we only need to specify a <code>@Column name</code> when the naming convention
is not followed.
</p>
<p>
Similarly we tend to not require explicit use of <code>@JoinColumn</code> or
<code>@JoinTable</code> as long as the naming convention
is followed (which defaults to "underscore naming convention").
</p>
<h2 id="collections"><a href="collections">Collections</a></h2>
<p>
Unlike Hibernate the recommendation with Ebean is to use <code>List</code> rather than <code>Set</code>
for mapping collections.
</p>
<h2 id="jpa-notes">JPA Notes</h2>
<p>
Ebean uses the same mapping as per the JPA specification. You can learn and use the
same mapping annotations. This is generally a good part of the specification and I'd
expect this part of the specification to mostly stand the test of time.
</p>
<p>
There are some aspects where JPA is generally insufficient.
</p>
<table class="table">
<tr>
<th width="25%">Enum</th>
<td>
Enum mapping in JPA is poor. Ebean provides 2 better alternatives in the form of <code>@DbEnumValue</code>
and <code>@EnumValue</code>. We are monitoring the progress of this issue in the JPA JIRA issue tracker.
</td>
</tr>
<tr>
<th>FetchType EAGER / LAZY</th>
<td>
<p>
JPA mapping encourages the use of FetchType.EAGER and LAZY which is contrary to Ebean's query approach
which instead looks to optimise the queries per use case (and provides automatic query tuning by
profiling the application).
</p>
<p>
The use of EAGER LAZY mapping annotations is generally not useful when using Ebean.
</p>
</td>
</tr>
</table>
<h2 id="validation-annotations">@Size and @NotNull</h2>
<p>
Ebean supports the use of <code>javax validation</code> annotations <code>@Size</code> and <code>@NotNull</code>.
</p>
<table class="table">
<tr>
<th width="25%">@Size</th>
<td>
Defines the mapped column width. For example, @Size(50) is equivalent to @Column(length=50)
</td>
</tr>
<tr>
<th>@NotNull</th>
<td>
Define the mapped column as non null. Equivalent to @Column(nullable = false) or @ManyToOne(optional=false).
</td>
</tr>
</table>
<h2 id="limitations">Current limitations</h2>
<p>
There are a number of JPA mappings that Ebean does not currently support
but would like to in time. These are logged as enhancement requests.
</p>
<table class="table">
<tr>
<td><a href="https://github.com/ebean-orm/ebean/issues/116">116</a></td>
<td>
<p>
Only single table inheritance is supported.
</p>
<p>
There is no planned support
for JOINED or TABLE PER CLASS inheritance strategies.
</p>
</td>
</tr>
<tr>
<td><a href="https://github.com/ebean-orm/ebean/issues/1777">1777</a></td>
<td>
<p>
Only a single type converter per type is supported.
</p>
<p>
JPA @Converter autoApply false is not honoured. This means that we expect
a type to be mapped consistently for all properties that it is used.
For example, we can't have two Converters mapping Boolean two different ways
in the same Ebean database instance.
</p>
</td>
</tr>
</table>
<p>
You can review the entire list of outstanding issue and enhancements in the
<a href="https://github.com/ebean-orm/ebean/issues">Github Issues</a>
</p>
<p>
Refer to github issues marked with the
<a href="https://github.com/ebean-orm/ebean/issues?q=is%3Aissue+is%3Aclosed+label%3ALimitation">Limitation</a>
tag.
</p>
<@next_edit "Naming convention" "naming-convention" "/docs/mapping/index.html"/>
</body>
</html>