facebook

Hibernate Wizards reports

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #215256 Reply

    krausest
    Member

    I run into an error with the Hibernate Wizard when I use the Hibernate Wizard via Database Exporer Perspective, choose a Table and click on Create Hibernate Mapping.

    In the dialog window (with the irritating title “New Hibernate Project”) I enter the following data:

    Path: /MyEcliipseTest/src/com (The project is called /MyEcliipseTest)
    Base Persistent Class: [Nothing specified]
    ID Generator: assigned

    Error message: Unable to update the Hibernate configuration file.

    Reason: Unable to create a new Hibernate XML Configuration file.

    Detail: Invalid path: /hibernate.cfg.xml

    No files are created.

    The strange thing is that when I open the project properties the page “MyEclipse-Hibernate” says: “No Hibernate config file specified”. Even if I browser for the hibernate.cfg.xml (which exists in /MyEclipseTest/src) and click on OK, the next time it’ll tell me again that no config file was specified.

    Further data: OS W2K SP 4, Eclipse 3.0.0 (200406251208), MyEclipse 3.8.1 (20040821200-3.8.1+QF20040825) Sun JVM 1.4.2_05-b04 Server VM, 5 org.eclipse.pde plugins,

    The .myhibernatedata contains the following data:
    #
    #Wed Sep 15 17:37:41 CEST 2004
    config.keyGenerator=
    config.password=
    configFile=/MyEcliipseTest/src/hibernate.cfg.xml
    libInstallFolder=
    addLibs2Classpath=false
    config.configFilepath=
    config.configFilename=
    config.name=
    addLibs2Project=false
    config.className=
    createConfigFile=false
    config.copyJarFiles=false
    config.basePersistenceClass=
    config.url=
    config.username=
    config.useDriver=false
    config.dialect=

    My hibernate.cfg.xml look like that:
    <?xml version=’1.0′ encoding=’UTF-8′?>
    <!DOCTYPE hibernate-configuration PUBLIC
    “-//Hibernate/Hibernate Configuration DTD 2.0//EN”
    http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd”&gt;

    <!– DO NOT EDIT: This is a generated file that is synchronized –>
    <!– by MyEclipse Hibernate tool integration. –>
    <hibernate-configuration>

    <session-factory>
    <!– properties –>
    <property name=”connection.username”>HMGRR</property>
    <property name=”connection.url”>jdbc:oracle:thin:@localhost:XYZ:orask920</property>
    <property name=”dialect”>net.sf.hibernate.dialect.Oracle9Dialect</property>
    <property name=”connection.password”>WONTTELL</property>
    <property name=”connection.driver_class”>oracle.jdbc.OracleDriver</property>

    <!– mapping files –>

    <mapping/>

    </session-factory>

    </hibernate-configuration>

    I’ve added the empty <mapping> to remove the validation error, but even before I got the same error.

    The .log file contains only:
    !ENTRY com.genuitec.eclipse.hibernate 1 1 Sep 15, 2004 17:37:43.144
    !MESSAGE Error – unable to loadhibernate project metadatanull

    Have I found a bug or have you found a stupid user?

    Yours,
    Stefan

    #215267 Reply

    Riyad Kalla
    Member

    Stefan,
    What if you get rid of the “com/” at the end of your path in the wizard? Does it work then?

    You mentioned your cfg files is in your src/ dir, but in your path you are specifying 1 level deeper than that (src/com/) which seemed odd to me.

    #215315 Reply

    krausest
    Member

    So I selected Path = /MyEcliipseTest/src in the wizard. Is that what you suggested?
    I’m getting the same error.

    #215338 Reply

    snpe
    Member

    try change in .myhibernatedata line
    config.configFilename=
    with
    config.configFilename=hibernate.cfg.xml

    or
    delete .myhibernatedata and call add Hibernate again

    regards

    #215341 Reply

    Riyad Kalla
    Member

    I don’t know if this is intentional or accidental, but you are misspelling “MyEclipse” by adding 2 I’s in your example above and in your last post, is this intentional?

    #215496 Reply

    support-jeff
    Member

    The dialog title is my fault. Fixed for 3.8.2.

    The config file errors are more serious. I have seen this happen before, and one of our other developers addressed it. So I will get him involved. The key is in the error you posted:

    The .log file contains only:
    !ENTRY com.genuitec.eclipse.hibernate 1 1 Sep 15, 2004 17:37:43.144
    !MESSAGE Error – unable to loadhibernate project metadatanull

    The problem is not the hibernate.cfg.xml file, but rather that ,myhibernatedata has become corrupted or something. Did you try snpe’s suggestion and whack that file and re-add hibernate capabilities to your project?

    #215638 Reply

    support-michael
    Keymaster

    Stefan,

    I’ve been assigned to research this problematic behavior and am having difficulty replicating it. Can you provide a simple sequence of actions that I can use to replicate this problem?

    Example:
    1) Create Java project (foo)
    2) Add hibernate capabilities to Foo
    3) From Database Browser view select table and right-click “Create Hibernate Mapping”
    ….

    #215680 Reply

    krausest
    Member

    I’m afraid, but I can’t reproduce this behaviour. I created a Java Project and added hibernate support and it worked and I created a J2EE Web Project and added Struts and Hibernate Support and it worked as well in that case. The latter case is pretty similar to the project where I got this error.

    Another question: Are you going to add more flexibility when creating the mapping? I’ve often seen legacy databases with obscure naming conventions (A tables starting with a “T_” and all columns starting with “D_”). The wizard creates java names that I wouldn’t accept in production code (TUser and getDLastName / setDLastName). It would be good if either a rule could be set (like for normal getter and setter in Eclipse) or the mapping could be adjusted before creating the hibernate files and java classes.

    Yours,
    Stefan

    #215681 Reply

    support-michael
    Keymaster

    I have tried a number of scenarios and have not been able to corrupt the hibernate metadata. I’ll try the monkey test and just pound randomly on my test projects.

    A question, do you have your project under VisualSourceSafe (VSS) or other code mgmt facility that sets read-only attribute of the files it manages?

    Another question: Are you going to add more flexibility when creating the mapping? I’ve often seen legacy databases…

    Most definitely we have a large number of mapping enhancements in the queue for upcoming releases. Thanks for this info.

    #223752 Reply

    Jesse Clark
    Member

    I think I may have an instance of corrupted hibernate metadata. When I added Hibernate functionality to my project I initially put my hibernate package at org.truste.ecom.hibernate but I later decided that it should live in org.trutse.ecom.model.hibernate. So, I used Refactor->Move to move the initial package into org.trutse.ecom.model (which already existed in the project). Then I manually updated my HibernateSessionFactory class with:

     CONFIG_FILE_LOCATION = "/org/truste/ecom/model/hibernate/hibernate.cfg.xml" 

    . I then switched to the DB Explorer perspective and tried to create a mapping for a table in the database that I configured hibernate to use and recieved the error “Unable to update Hibernate XML configuration file: Reason: Unable to create new Hibernate XML configuration file: Details: Error creating Hibernate config file: hibernate.cfg.xml”.

    After reading this forum topic I took a look at the .myhibernatedata for my project and saw this value:

    configFile=/ecommerce/src/org/truste/ecom/hibernate/hibernate.cfg.xml

    which reflects the location of the config file before I moved it with Refactor. I tried using refactor to move it the config file around and changing the value of the field in the ServiceFactory but it had no effect on the metadata file. I also tried restarting Eclipse to see if it would write the correct metadata when it saved the workspace but that also had no effect.

    So, I then tried editing the metadata to have the correct config file path, but I still got the error trying to create the mapping.

    And lastly, I just noticed that there is another value in the metadata file:

     
    config.configFilepath=/ecommerce/src/org/truste/ecom/hibernate

    which also pointed to the incorrect directory. After updating this value, I was able to create the mapping.

    I am using Eclipse 3.0, MyE 3.8.3, JDK 1.5, FedoraCore 2, PostgreSQL 7.4.2, on FedoraCore 2, I don’t have any other plug-ins installed, I did a fresh Eclipse install when installing MyEclipse. Prior to trying to add Hibernate capabilities to this project I had created a new project in the same workspace and used it to complete the demo app in the Hibernate Tutorial in the MyEclipse help documents. The first project also had the config file located at /ecommerce/src/org/truste/ecom/hibernate.

    Hope this helps,
    -jesse

    #223754 Reply

    support-jeff
    Member

    Refactoring to move the config file does not alter the .myhibernatedata file content. You must update it yourself (as you did), or remove it altogether and then re-add Hibernate Capability to your project (you will not need to create a new config file, just tell the wizard to use the old one at its new location.

    #223915 Reply

    Jesse Clark
    Member

    It would be a nice feature add if MyEclipse would work with the refactor tool. The hibernate issue above is one example. Another would be using the refactor menu option to move or rename jsps and having the struts-config.xml and maybe even referencing jsps get automagically updated….

    Thanks,
    -jesse

    #223918 Reply

    Riyad Kalla
    Member

    Jesse,
    We agree, these are all filed enhancements that we just need some time to get around to adding. Sorry for the inconvenience.

    #223949 Reply

    support-jeff
    Member

    Jesse –

    Just remembered that you can also change the location of the hibernate config file for a project by opening the project Properties dialog and going to MyEclipse-Hibernate. THere is a text box there with the file listed and you can edit the location here.

    #224635 Reply

    Jesse Clark
    Member

    I moved the hibernate config file to /src/conf from /src/java and changed the location in the project properties as you indicated and when I added another hibernate mapping from the Database Explorer the config file got regenerated in the /src/java folder.

    Then as a test I removed all my mappings and the config file and created a new hibernate mapping. This time the mapping got generated in the same source directory as my HibernateSessionFactory.

    Here is my .myhibernatedata file:

    #
    #Mon Feb 07 14:54:30 PST 2005
    config.password=not_this
    config.name=java\:comp/env/jdbc/postgres
    config.mappings[0]=org/my_client/ecom/model/ApplicationUser.hbm.xml
    config.username=not_this
    config.dialect=net.sf.hibernate.dialect.PostgreSQLDialect
    config.className=net.sf.hibernate.transaction.JTATransactionFactory
    config.configFilepath=/ecommerce/src/java
    config.mappings[1]=org/my_client/ecom/model/RoleUserLink.hbm.xml
    libInstallFolder=/webroot/WEB-INF/lib
    addLibs2Project=true
    config.url=
    config.configFilename=hibernate.cfg.xml
    config.useDriver=false
    configFile=/ecommerce/src/conf/hibernate.cfg.xml
    createConfigFile=true
    config.mappings[2]=org/my_client/ecom/model/Role.hbm.xml
    addLibs2Classpath=true
    config.basePersistenceClass=
    config.keyGenerator=native
    config.copyJarFiles=false

    Note the two different config file locations in bold. Also, those two config mappings that it lists were removed days ago. This is how the .myhibernatedata file looked after generating a mapping for the ApplicationUser class.

    Am I doing something incorrectly here?

    Thanks,
    -jesse

Viewing 15 posts - 1 through 15 (of 20 total)
Reply To: Hibernate Wizards reports

You must be logged in to post in the forum log in