ORM2 and Netbeans, quick and dirty how to

0 views
Skip to first unread message

Vlasta Seliga

unread,
Feb 22, 2008, 9:31:02 AM2/22/08
to gwtsandbox
Finally, I'm able to use ORM2 with Netbeans. (I'm using Netbeans 6.0.1
with GWT plugin).

I'm no GWT guru, so after some time I give up idea that I'll be able
to use ORM2 as another library (like gwt-common-loggin) because I run
into some issue. (I'll discuss it later.)

Steps to follow:

1) First create new GWT Netbeans project add support for GWT
framework, I entered com.solvina.Main as module name, this class is
entry point to the application, add all necessary libraries (Google
APIs, velocity-1.5, commons-lang)

2) Then add to project packages from ORM2 (simply copy them into
project)
com.google.gwt.gears.database.client
com.gwtsandbox.gears.orm.rebind
com.gwtsandbox.gears.orm.rebind.tmpl
Also it is necessary to have in your client package (in my case
com.solvina.client) those classes from ORM2:
GearsDataObject
GearsDataStore
GearsQuery

3) Now some hacking is necessary. In class
com.gwtsandbox.gears.orm.rebind.GearsDataStoreGenerator in method
getSourceWriter() are hardcoded in these lines:

composerFactory.setSuperclass("com.gwtsandbox.gears.orm.client.GearsDataStore");
composerFactory.addImport("com.gwtsandbox.gears.orm.client.GearsDataStore");
composerFactory.addImport("com.gwtsandbox.gears.orm.client.GearsQuery");

it is necessary to change them to proper values (again, in my case to
"com.solvina.client.GearsDataStore" and
"com.solvina.client.GearsQuery")

4) go to your project's properties -> Libraries and add to your
classpath directory (by Add Jar/Folder button) where your Netbeans
stores compiled classes - in my case $PROJECT/build/web/WEB-INF/
classes (this direcotry is automaticly created when Netbeans starts
compile the project)

Now you (and your Netbeans) are ready to follow the steps in Robert's
examples. (Like edit *.gwt.xml, write pojo, bring eternal happiness
for all obese children...)
Warning! You still have to update your Main.gwt.xml file. When I was
checking this instructions I ended with something like this:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<inherits name="com.google.gwt.user.User"/>
<entry-point class="com.solvina.client.MainEntryPoint"/>

<inherits name='com.google.gwt.gears.Gears'/>
<!-- Do not define servlets here, use web.xml -->
<generate-with
class="com.gwtsandbox.gears.orm.rebind.GearsDataStoreGenerator">
<when-type-assignable class="com.solvina.client.GearsDataObject"/>
</generate-with>

</module>


The main obstacle was 4, I was fighting with com.gwtsandbox not found
exception for long time.

If you run into some problems, please try to solve them by
ourself :-). The above is result of (more than) one day try-and-fail
painful procedure and I gained no special powers during this time - so
most likely I will be not able to help you if you run into some
problems.
But if you find some shortcuts, mistakes, improvements, bugfixes don't
hesitate and share them ;-)

----- Suggestion
Because of step 3, it is impossible to have the ORM2 standalone :-
( (and moreover: I don't know if is possible to have GWT generator in
standlone library, but I hope it will be possible - at least I don't
see why this should be a big problem)
Those values should be in some property - unfortunately I'm not
skilled in GWT to be able to put into Main.gwt.xml, it would be nice
to have it like this:
<generate-with
class="com.gwtsandbox.gears.orm.rebind.GearsDataStoreGenerator">
<when-type-assignable class="com.solvina.client.GearsDataObject"/>
</generate-with>

<set-property name="GearsDataStoreClass"
value="com.solvina.client.GearsDataStore" />
<set-property name="GearsQueryClass"
value="com.solvina.client.GearsQuery" />

---Question
Reply all
Reply to author
Forward
0 new messages