For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 7 replies, 4 voices, and was last updated 18 years, 3 months ago by
Riyad Kalla.
-
AuthorPosts
-
I was wondering why, since MyE looks inside the database, it picks an incorrect PK generator.
Here’s the situation….
I have the PK set to auto generate in MySQL (no nulls, PK = true) in my users table.
Yet, MyEclipse sets the PK generator to “Assigned” (in the users mapping file) which fails (crash) when I try to run any code…I have to manually change the generator name to “increment”.
Is this a bug in MyEclipse? It seems it should know how to handle this generator type and set the type correctly.
Thanks in advance.
M
May 5, 2008 at 9:51 am #284668
Loyal WaterMemberOn the second page of the reverse enginnering wizard, choose the ID Generator as increment in the drop down box.
May 5, 2008 at 10:00 am #284669I understand what you’re saying, but my point is this:
If MyEclipse is already looking “inside the database”, why can’t it understand that the default generator will crash when you try to run the code?
Seems like MyE should be smart enough to figure out that if PK generation is automatic (in MySQL), it needs to be increment by default (not by user selection of a drop down).
M
May 5, 2008 at 10:19 am #284672
Riyad KallaMemberMork, it’s true that we should be picking this automatically. Unfortunately to make it consistently accurate across most databases it isn’t that easy. So for now you have to manually select your generator. Auto-selection is on our TODO list.
May 5, 2008 at 12:04 pm #284677Sounds good, thanks.
For the moment, I think I’m headed back to regular JDBC code.
MyEclipse doesn’t help me enough — I can’t even get a simple 1:M example working after several days…(no working documentation on this or M:M, etc.).
Thanks for all your replies.
M
May 8, 2008 at 8:29 pm #284818
TonyHHMemberIMHO – I don’t think it’s such a big deal if you know Hibernate. It’s only annoying when you’re learning in which case it’s probably best to learn from these little things.
May 9, 2008 at 5:52 am #284828Thanks TonyHH for your reply!
For my 1:M example, I posted my mapping (on another thread on this forum) files and the java “main” class I tried to use to write the many side of the database tables (as well as the 1 side).
The 1 side works, but the many side doesn’t. I’m sure the problem is minor but finding really good examples doesn’t appear to be as easy as I expected.
For example, I can’t find *any* 1:M Hibernate examples actually using MyEclipse.
If you see what’s wrong with my mapping files or the Java code that populates a Java Set to populate the many side, please drop me another note, OK?
The “PK” is correctly generated on the 1 side, but it that PK from the 1 side needs to be used as an FK on the many side for linking. Since no row is being generated on the many side, I’m thinking there may be some kind of PK or FK problem. Not sure.
Thanks again for posting.
M
May 9, 2008 at 10:55 am #284835
Riyad KallaMemberFor my 1:M example, I posted my mapping (on another thread on this forum) files and the java “main” class I tried to use to write the many side of the database tables (as well as the 1 side).
The 1 side works, but the many side doesn’t.
Mork, I posted the solution for you in the other thread (you need to use the cascade attribute on the relationship to force persistence operations (insert or delete) from the one to the many).
For example, I can’t find *any* 1:M Hibernate examples actually using MyEclipse.
I made a custom one for you and posted in detail how to use it IIRC (using the included example DB schema CLASSICCARS in MyEclipse)… it was related to the EMPLOYEE and OFFICE entities. (If I forgot to post the project let me know and I’ll forward it along)
-
AuthorPosts

