Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
207 lines (189 sloc) 6.82 KB
<html>
<head>
<meta name="layout" content="_layout/docs_mapping.html"/>
<#assign overview = "true">
</head>
<body>
<div class="container">
<h5>Types</h5>
<div class="row">
<div class="col-md-9">
<b>
<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/db-array">DB Array</a>,
<a href="/docs/mapping/type/db-json">DB Json</a>,
<a href="/docs/mapping/type/">Other</a>
</b>
</div>
</div>
<p>&nbsp;</p>
<h5>JPA mapping</h5>
<div class="row">
<div class="col-md-3">
<h5><a href="/docs/mapping/id">@Id</a></h5>
<h5><a href="/docs/mapping/version">@Version</a></h5>
<h5><a href="/docs/mapping/mapped-superclass">@MappedSuperclass</a></h5>
</div>
<div class="col-md-3">
<h5><a href="/docs/mapping/one-to-many">@OneToMany</a></h5>
<h5><a href="/docs/mapping/many-to-one">@ManyToOne</a></h5>
<h5><a href="/docs/mapping/one-to-one">@OneToOne</a></h5>
<h5><a href="/docs/mapping/many-to-many">@ManyToMany</a></h5>
</div>
<div class="col-md-3">
<h5><a href="/docs/mapping/lob">@Lob</a></h5>
</div>
</div>
<h5>Ebean mapping</h5>
<div class="row">
<div class="col-md-3">
<h5><a href="/docs/mapping/dbjson">@DbJson</a></h5>
<h5><a href="/docs/mapping/dbarray">@DbArray</a></h5>
<h5><a href="/docs/mapping/dbarray">@DbHstore</a></h5>
<h5><a href="/docs/mapping/dbcomment">@DbComment</a></h5>
<h5><a href="/docs/mapping/dbpartition">@DbPartition</a></h5>
</div>
<div class="col-md-3">
<h5><a href="/docs/mapping/when-created">@WhenCreated</a></h5>
<h5><a href="/docs/mapping/when-modified">@WhenModified</a></h5>
<h5><a href="/docs/mapping/who-created">@WhoCreated</a></h5>
<h5><a href="/docs/mapping/who-modified">@WhoModified</a></h5>
</div>
<div class="col-md-3">
<h5><a href="/docs/mapping/view">@View</a></h5>
<h5><a href="/docs/mapping/soft-delete">@SoftDelete</a></h5>
<h5><a href="/docs/mapping/encrypted">@Encrypted</a></h5>
<h5><a href="/docs/mapping/read-audit">@ReadAudit</a></h5>
<h5><a href="/docs/mapping/history">@History</a></h5>
<h5><a href="/docs/mapping/formula">@Formula</a></h5>
<h5><a href="/docs/mapping/change-log">@ChangeLog</a></h5>
</div>
</div>
<div class="row">
<div class="col-md-4">
<h4 id="constructors"><a href="constructors">Constructors</a></h4>
<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>
<h4 id="collections"><a href="collections">Collections</a></h4>
<p>
Unlike Hibernate the recommendation with Ebean is to use <code>List</code> rather than <code>Set</code>
for mapping collections.
</p>
</div>
<div class="col-md-4">
<h4 id="naming-convention"><a href="naming-convention">Naming convention</a></h4>
<p>
Ebean uses a Naming convention API. This is relatively important as it typically it
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>
</div>
</div>
</div>
<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 to 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>
You can’t perform that action at this time.