You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ode.apache.org by ShaoGuang Geng <sh...@yahoo.com> on 2007/09/06 08:28:46 UTC
Hoe could I create table from JPA annotations
Hi, every one,
I'm just investigating the ode's coding frame. I have a small problem need your help.
I want to generate tables or schemas from JPA's annotation, but don't know how. Could some of you give me a clue?
(Of course Rake did it, but I want a more general way.)
Thanks.
---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
Re: Hoe could I create table from JPA annotations
Posted by Alex Boisvert <bo...@intalio.com>.
On 9/5/07, ShaoGuang Geng <sh...@yahoo.com> wrote:
>
> I want to generate tables or schemas from JPA's annotation, but don't know
> how. Could some of you give me a clue?
You can use the OpenJPA schema tool [1] with the persistence descriptors
found under dao-jpa-ojpa-derby/src/main/descriptors. To get a complete
schema for Ode, you'll have to merge the generated SQL with the
SimpleScheduler schema since it uses raw JDBC (see
dao-jpa-ojpa-derby/src/main/scripts).
This is essentially what the Rake build does (for each supported database):
%w{ derby mysql oracle }.each do |db|
db_xml = _("src/main/descriptors/persistence.#{db}.xml")
scheduler_sql = _("src/main/scripts/simplesched-#{db}.sql")
partial_sql = file("target/partial.#{db}.sql"=>db_xml) do |task|
mkpath _("target"), :verbose=>false
Buildr::OpenJPA.mapping_tool :properties=>db_xml, :action=>"build",
:sql=>task.name,
:classpath=>projects("bpel-store", "dao-jpa", "bpel-api",
"bpel-dao", "utils" )
end
sql = concat(_("target/#{db}.sql")=>[_("src/main/scripts/license-
header.sql"), partial_sql, scheduler_sql])
build sql
end
alex
[1]
http://openjpa.apache.org/builds/1.0.0/apache-openjpa-1.0.0/docs/manual/ref_guide_schema_schematool.html