- This topic has 11 replies, 4 voices, and was last updated 17 years, 10 months ago by Haris Peco.
-
AuthorPosts
-
MartinMemberHi,
I tried to create a mapping with the Hibernate Reverse Engineering tool. I already have a POJO for the table, so I don’t want MyEclipse to create one. But specifying the class name in the table details of the wizard has no effect: the generated mapping file contains a default POJO class with the same package of the mapping file and with the same name as the table – my POJO is in a different package and has a different name as the table.
It’s the same with properties: all columns are mapped to TableName.columnName instead of “PojoName.propertyName”, what I specified in the wizard.
What am I missing?
Brian FernandesModeratorHi,
Could you tell us what version of MyEclipse you are using? There was a problem with the class name specification which has been fixed in 5.1GA.
Also, the class name must be a fully qualified name.We don’t really allow you to map to an existing class, the RE tool will always generate a new POJO each time (if you choose to use Abstract generation, then only the Abstract class will be overwritten each time you generate).
Your other options are to simply not generate a POJO for the table in question – if you just want to create the mapping in the configuration file, use the hibernate configuration editor.Hope this helps.
MartinMemberI’m using Version: 5.1.0 GA, Build id: 20061111-5.1.0-GA on Windows XP.
I did specify the fully qualified name of the class (Content Assist would be great here). It makes no difference if generating POJOs or not, the referenced class is always named as described.
BTW: Mapping to an existing class in a graphical way would be a killer, e.g. by drawing lines between an ER diagram of the table and an UML diagram of the class.
Brian FernandesModeratordid specify the fully qualified name of the class (Content Assist would be great here). It makes no difference if generating POJOs or not, the referenced class is always named as described.
Are your settings persisted? i.e. When you go to the same page the next time you reverse engineer, do you see the FQN you entered the last time? Be advised that this could overwrite your existing POJO – unless you enable Abstract generation; there is no content assist provided because that field is not used to specify an existing class, but to specify a customized name for class which will be generated instead of using the engines internal logic to come up with name for the class.
Also, could you please paste the contents of your error log here? There could be some invalid settings in your RE file which could cause the all the RE settings to be ignored. More instructions on the error log here: Posting Guidelines
Mapping to an existing class in a graphical way would be a killer, e.g. by drawing lines between an ER diagram of the table and an UML diagram of the class.
🙂 I agree, a visual mapper is on the cards.
MartinMemberYes, the settings are persisted. It’s just that the string entered here does not make it into the hbm.xml file.
Here’s the error log: something obviously fails …
!SESSION 2007-01-17 13:00:53.005 ----------------------------------------------- eclipse.buildId=M20060921-0945 java.version=1.5.0_08 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE Command-line arguments: -os win32 -ws win32 -arch x86 !ENTRY org.eclipse.wst.internet.cache 1 0 2007-01-17 13:01:10.365 !MESSAGE wtp.autotest.noninteractive is set. Licenses dialogs will not be displayed. !ENTRY com.genuitec.eclipse.hibernate 1 0 2007-01-17 13:03:17.335 !MESSAGE Error processing rev-eng settings file !STACK 0 org.hibernate.MappingException: Could not configure overrides from file: D:\Projekte\procon-s\trunk\implementierung\core\hibernate.reveng.xml at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:79) at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.run(GenerateArtifactsJob.java:275) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58) Caused by: org.hibernate.MappingException: jdbc-type: boolean is not a known JDBC Type nor a valid number at org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper.getJDBCType(JDBCToHibernateTypeHelper.java:119) at org.hibernate.cfg.reveng.OverrideBinder.bindColumns(OverrideBinder.java:155) at org.hibernate.cfg.reveng.OverrideBinder.bindTables(OverrideBinder.java:56) at org.hibernate.cfg.reveng.OverrideBinder.bindRoot(OverrideBinder.java:37) at org.hibernate.cfg.reveng.OverrideRepository.add(OverrideRepository.java:130) at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:109) at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:75) ... 2 more
I played around with various settings when using the wizard, some of them seem to be responsible for this error. At least a “something failed, see the error log”-message would be helpful at this point.
After removing the reverse-engineering file, everything works as expected. Anyway: assistance when mapping properties (to existing beans) would be helpful. I will wait for the visual mapper … 😉
Thanks for your help.
Brian FernandesModeratorOn page 2 of the RE wizard, you probably have an entry where the JDBC type specified is “boolean”. This is not a valid JDBC type, if you just delete that entry your RE settings should be taken into account. Alternatively you can delete your existing hibernate.reveng.xml file and start with a new one.
I played around with various settings when using the wizard, some of them seem to be responsible for this error. At least a “something failed, see the error log”-message would be helpful at this point.
I agree, coincidentally, we happened to discuss this issue a day ago and will be adding better feedback in 5.5M1.
Anyway: assistance when mapping properties (to existing beans) would be helpful.
Could you give me an idea of what you expect the tool to do? You already have the POJO, so you don’t need the POJO generation, do you want just the mapping file (hbm.xml) generation? I reiterate, if you enable POJO generation and specify a custom classname, that class will be overwritten by the gneration process (if you enable abstract class generation on page 1, AbstractClassName.java will be overwritten, while ClassName.java will be left untouched).
MartinMemberWith “assistance when mapping properties” I just meant that the wizard should help me specifying the properties of the Pojo. I now just specify the destination Pojo, generate the mapping file, and then manually edit it while using code completion, which works like a charm. So there’s no real need by now to use the wizard for this. (while a visual mapping tool would be much cooler, indeed 🙂 )
BTW: code completion of properties does not work with key-properties inside a composite-id.
Brian FernandesModeratorI’m glad you managed to find a good work flow and are enjoying the editor 🙂
code completion of properties does not work with key-properties inside a composite-id.
I tried this and it did work, do you mean something like this?
<composite-id name="id" class="com.foo.MyIdClass"> <key-property name="e<-Invoke code completion here
MartinMemberHmm, it seems, that I confused something: no, it’s not completion of the property, but of the column name, someting like this:
<composite-id name="id" class="com.foo.MyIdClass"> <key-property name="elfkjb" type="java.lang.String"> <column name="e<-Invoke code completion here
… and it’s not about composite keys, it’s with every column element. Is this supposed to work, anyway?
Haris PecoMemberMartin,
No, table/column code completion doesn’t work in current release of MyEclipse.
Regards,
kagitalaMemberI want to generate pojos and mappings automatic.
how to generate both can u ples explain me urgent.i am using myclipse latest version.
Haris PecoMemberkagitala,
Start with Hibernate Quick start : Help>MyEclipse Learning Center>Spring/Hibernate development>Hibernate Development
Regards
-
AuthorPosts