Discussion:
[Middlegen-user] Re: middlegen-user digest, Vol 1 #373 - 2 ms gs
Ed Ross
2003-07-22 19:27:02 UTC
Permalink
Hi Qin,

Here is my experience in using middlegen

1 - I had to take all of the dependencies (in the ant build.xml) from
<target name="middlegen"... I did this because each time I ran ant, it would
re-gen all the tables. That would not be so bad, but as you increase the
number of tables, it starts to take a very long time.

2 - In the build.properties I had to set gui="false". Again, as you get
lots of tables, the gui doesn't do much for you.

3 - When you have a table name and the primary key with the same as the
table name, you will get some problems. In my case, this was common
practice when the first application was developed so we need to just deal
with it. (Example table name = patients, Primary key = patient)(NOTE
Middlegen will change the plural name to singlar - which I happen to like)
When this happens, you need to include the tables defintion in the ant
build.xml (e.g.

<table generate="true" name="patients" singular="indPatient"
plural="patients" />
)
here I can change the name of the singular to indPatient and the referencing
code will be
getIndPatient() rather than getPatient()

Trouble with this approach is that once you specify any table, you need to
specify all tables. When you have hundreds this could be a pain.

In your case, it might not be so bad as you could define the county table as
read only. (If you figure out how to do this, let me know)

You will still have errors in the struts stuff, but, that's easier to deal
with (Only use a few of the generated struts stuff, the remainder I just
delete - another reason I don't like to regen the tabels)


Primary key (with auto generate). You could use the autogen if you care to,
but this presents some strange problems (at least for me). On most cases, I
need the ID that was just generated to set up some other releationships. If
the ID is autogen'ed, you don't have this until the database is written,
then you have to do a find where max(key) to get the key. Turns out, rather
than saving time (by using the autogen), it costs more. I'm not sure how
your app server deals with this, but I assume it masks it from you.

Another note, the "off-the-self" version of middlegen, has a bit of a
problem with native types (int, byte, ...) when the column may contain
nulls. Middlegen will generate native calls (e.g. int getPatientAge(),
rather than Integer getPatientAge() ) whill will cause null pointer
exceptions when the value on the database is null. There is a patch that
should be applied before you get to far.

So far, I would say my experience with middlegen has been very good.
Without it, or something like it, would put my project way out of scope. My
biggest problem is the lack of documentation and an easy "how to guilde" I
would consider doing this, but I just don't know it well enough.


Good luck to you and special thanks to Aslak

ed

-----Original Message-----
From: Aslak Hellesøy [mailto:***@thoughtworks.net]
Sent: Tuesday, July 22, 2003 4:54 PM
To: middlegen-***@lists.sourceforge.net
Subject: Re: [Middlegen-user] Re: middlegen-user digest, Vol 1 #373 - 2
msgs
I am new to the middlegen. After downloaded the middlegen, I followed the
demo and get-start document. It looks great. I decided to learn more. I
used firebird as my business database. First I try the Employee.gdb, which
is the example database come along with the firebird download. Here is my
Hi Qin.

I have tried to answer some of your questions. I hope someone else on
this list can fill in the missing parts.
Our bug tracker is currently at:
http://jira.codehaus.org/secure/BrowseProject.jspa?id=10110
1. When loading many tables ( in hundreds in an enterprise information
system) into middlegen GUI, how do I hide and unhide the tables, so they
are not so crowded? Like in Microsoft Access DB Relationship view.
This is currently not supported. Please file a feature request.
2. If there are no relationships shown between two tables as in GUI, is
there a way I can draw a line to build the relationships like in Microsoft
Access DB Relationship view.?
Declaring relationship after scanning is currently not supported.
However, you can use the crossref Ant element to declare relations that
are not declared (as foreign key references) in your database. If you
want to be able to do this in the GUI, please file a feature request.
3. In firebird, when a data type is SmallInt, it is mapped to
java.lang.Short. What is the mapping file used and where is it located if
I use JBoss as my App Server?
The mapping logic is in Sql2Java.java (http://tinyurl.com/hq0v)
4. In firebird, a trigger is used to populate the primary key (type of
smallint). How do I tell middlegen not to populate the bean id field,
because when the bean get saved to the database, I guess the key is
automatically generated by the trigger.
Supposing you're using Middlegen to generate CMPs, try one of the three
built-in pk generation schemes:
http://boss.bekk.no/boss/middlegen/plugins/cmp20.html
If that doesn't work for you, please file a deature request.
5. Because the pk field is smallint -> Short, I received the error
Short(int) can't be resolved. Middlegen sequenceGenerator generates an id
of type int, which is a param passed to the Short constructor. I have to
use the middlegen GUI to change all key field (pk and fk) from smallint to
int, the error goes away. However, I am worried that in database the type
remains as smallint, in java object it is int. What happens when the id
get very big for the smallint to hold?
6. Is there an easy way to make changes from one type to another in GUI or
in ant task? If I have over hundred tables and much more fields from
existing enterprise database, I feel we can configure the middlegen to take
int type whenever it finds a smallint.
7. In db, I have a country table, which is referenced by several tables.
When I compile the java source, I get an error stating that getCountry is
already defined. Same in department table which is referenced by many
tables. The error states that getDepartment() is already defined. Because
I do not write any business code in this exarcise, every thing is generated
by middlegen by reading in database meta info, it makes wonder I perhaps
have to adjust the relationships somehow. I don't know what and how,
though. What's the problem here? And where I should look in order to avoid
this problem?
8. Where can I find the document (a complete user guide) on all the
relationship attribute like (many2many). What else do we have (one2one,
one2many)?
9. I heard that in middlegen next version includes a hibernate plug-in?
How soon the next version will be released?
There is no schedule, but we're working on it. Maybe in a 2-3 months.
It is a great tool. Keep up the good work.
Thanks,
Aslak
Qin
---------------------------------------------------------------------------
-------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
---------------------------------------------------------------------------
-------------
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
--
http://blogs.codehaus.org/people/rinkrank/




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
middlegen-user mailing list
middlegen-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/middlegen-user
This E-mail message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply E-mail, and destroy all copies
of the original message.
Loading...