Is there a way to auto-generate hibernate.cfg.xml file in netbeans/eclipse? - eclipse

Actually i'm learning jpa, so i must learn with examples.
I found that the manual creation of hibernate is annoying,
every time i have to copy and paste the structure of that file
So i was thinking is there any solution to auto-generate the " hibernate.cfg.xml " file automatically via netbeans/eclipse ?

Netbeans automatically generates a hibernate.cfg.xml if you create a Web Application Project that uses Hibernate (see the Netbeans documentation on Using Hibernate in a Web Application). According to this guide, you can also create the hibernate.cfg.xml file using New → Other and then selecting Hibernate Configuration Wizard in the Hibernate group.
In Eclipse, the Hibernate Tools plugin provides a wizard to create the hibernate.cfg.xml file (see the JBoss Hibernate Tools documentation).
Edit: Add information about the file wizard in Netbeans.

Related

Spring Roo. Deleting .aj archives without generating new ones

I have installed the Roo Shell 2.0.0.RELEASE in my eclipse. I have never worked with Roo, but, as I understood, it will regenerate the .aj files of my imported roo project when I modify something in them.
However, when you open the projects, it just delete the .aj with commands like this:
roo> Deleted SRC_MAIN_JAVA\com\bbva\front\oorg\cirbe\cirbedaos\dto\vinculaciones\DetalleVinculacionesDaoOutDto_Roo_JavaBean.aj - not required for governor com.bbva.front.oorg.cirbe.cirbedaos.dto.vinculaciones.DetalleVinculacionesDaoOutDto
I don't know if I should write or configure something else, since most manuals I see only say that the Shell should generate these files automatically. Any idea about what im missing?
Indicate that I think the project used to work with shell 1.1.5 (i imported an existing project), but I was unable to open it, so I used 2.0.0. It is assumed that Roo has also updated this in the POM files:
Updated ROOT\pom.xml [updated property 'roo.version' to '2.0.0.RELEASE'; updated property 'roo.version' to '2.0.0.RELEASE']
Spring Roo uses the annotations included in your .java files to generate the .aj files. Each version of Spring Roo could provide/deprecate different annotations. Spring Roo 2.x is a major update, and it does not support some of the annotations of Spring Roo 1.x
https://docs.spring.io/spring-roo/docs/current/reference/html/#no-backward-compatibility
As you said, the project was created with the 1.x version of Spring Roo, so the generated code included annotations that are not supported by the 2.x version of Spring Roo. That is the reason because your .aj files are being removed with the message not required for governor.
Also, I guess that a warning message appeared to you in the Spring Roo shell before to open the project.
Hope it helps.

Eclipse+STS or STS all function invalid

I follow some guide, In the video, Their IDE have all those functions (by default! no config needed):
No auto compile in any type
No Spring entry in "NEW" or "XML Configure File" in XML or anything handy
No Spring XML editor in "OpenWith"
etc....
Almost everything is missing
I try both way: Download STS4 or install STS in Eclipse
None of them working
So: How to get those lost function ?
The tutorial you are following is probably using STS3, which contains all the features for Spring XML config files that you mentioned. However, the tooling that you have installed is Spring Tools 4 for Eclipse, which comes with a different set of features. It supports Spring XML config files, too, but in a different way. It is much more focused on implementing apps on top of Spring Boot. You can find more details in the Spring Tools 4 wiki: https://github.com/spring-projects/sts4/wiki

How to get eclipse content assist working in XML files

I have started creating the Spring web application where I need to mention the spring classes in the XML configuration files, for ex, the deployment descriptor (web.xml) where I need to mention the DispatcherServlet class of Spring.
What I am looking for is, I want eclipse to show me the list of packages/classes when I type org.springframework..., like we do in the Java editor. I have googled to find out, but no luck. I am sure there would be plugins available. Can any of you please share me on how to fix this?
Since you are working on a spring project, I'd recommend installing the SpringToolSuite (STS). The info page is here: http://spring.io/tools
Since you already have an Eclipse instance that you are working with, you should go with the update sites: http://dist.springsource.com/release/TOOLS/update/e4.4/
(Make sure to use the correct update site for the Eclipse version you are using.)
Not only does STS include all tools for XML editing, but it also includes special tools for editing your Spring application files.

hibernate console configuration disappeared in Eclipse

I'm working with Eclipse Indigo and the Hibernate tools/plugins (3.4.0...) by JBoss Red Hat. For the purpose of reverse engineering of Hibernate value object classes I created several console configurations with the wizard that pops up when clicking on add in the Hibernate Configurations view.
Later when I wanted to regenerate the classes, some of the configurations had dissapeared. When I wanted to add a new configuration with the name of one of the now dissapeared configurations the wizard tells me that the configuration already exists.
Since I couldn't find out where these configurations are stored I'm unable to do anything about it.
Do I have to create a new configuration with a different name?
I have the same problem and finally I found the file in this directory:
.\WORK-SPACE\.metadata\.plugins\org.eclipse.debug.core\.launches\miConsoleConfig.launch
But is better to edit from eclipse. The console configuration is only visible in Hibernate perspective under tab Hibernate Configurations next to the package explorer.

Spring Explorer not showing beans from bean definition file

I just downloaded the Springsource Tool Suite, and I created a simple bean configuration file called myDefinition.xml and placed it in the root directory of the Spring Project. However, the Spring Explorer is not showing any data. I'm using eclipse 3.5 and the latest SpringSource all-in-one installation.
Also, if I specify invalid property names in the configuration file, I get no error. Autocomplete, however, is working.
Thoughts?
In the Spring Explorer tab in Eclipse, right click on your project > properties. Then go to Spring > Beans Support and select the Config Files tab. You can then select files or scan a directory and that should add them. I haven't found a way to autoscan a directory so I don't have to do this whenever I add a new spring bean file. The beans that appear in that list are stored in the .springbeans file.
Just want to add that if you want to generate a diagram of a webflow of an existing project, you have to right-click said project in Eclipses Project Explorer and "Add Spring Project Nature" by using the Spring Tools entry of the context menu.
There currently (as of 2012-04-10) seem to be problems with the Spring Explorer view when using a purely annotation driven bean definition (i.e. using Java annotations to wire everything up instead of using XML files).
There is a workaround though, by providing a minimum XML file that declares scanning for components.
http://forum.springsource.org/showthread.php?118928-Spring-Explorer-with-Java-based-Web-Container-configuration
Unfortunately, this procedure is still flawed, missing some components.
Just to add Claudio030
Make sure you have JEE perspective selected for your project, otherwise it won't show in Java perspective.