1 2 Previous Next 20 Replies Latest reply on Oct 9, 2009 11:04 AM by John Verhaeg

    Generating DDL from annotated POJOs

    John Verhaeg Newbie

      I'm trying to figure out how to use the JPA/Hibernate-related functionality in JBDS 2.0 and am having a few problems with JBDS either locking up on me or doing nothing when I choose the JPA Tools->Generate DDL... context menu option. I'm starting with JPA-annotated classes from which I want to generate SQL Server DDL. I want to eventually use Teiid to map my JPA objects that represent my domain-specific business view to the actual physical tables defined in the database (i.e., the JPA business objects do not currently match the database schema). I can provide the actual project and its contents, plus the URL to the database source, if that would help (but the latter is only available on the intranet).

        • 1. Re: Generating DDL from annotated POJOs
          Max Rydahl Andersen Master

          What database are you running against ?
          Are the database actually online/connected ?

          Anything in the Error Log View ?

          • 2. Re: Generating DDL from annotated POJOs
            John Verhaeg Newbie

            As I indicated in my initial question, I'm trying to generate DDL for SQL Server. The database is online and accessible via the Data Source Explorer, but not otherwise sure what you mean by connected. I'm just trying to generate DDL; why would I need to be connected to the database?

            Regarding the error log - doh, should've looked at that. Whatever happened to Eclipse opening that view automatically when an error occurs (The Active on New Events option was checked)? Anyway, I do have an error - Class not found for the SQLServerDriver class, which makes no sense to me since the Data Source Explorer finds it just fine.

            • 3. Re: Generating DDL from annotated POJOs
              John Verhaeg Newbie

              Guess I should also mention that the ClassNotFoundException was embedded within a HibernateConsoleRuntimeException.

              • 4. Re: Generating DDL from annotated POJOs
                Max Rydahl Andersen Master

                I was sure I answered this issue already, but apparently that got lost somehow.

                You need to add the driver to the classpath of the project or console configuration in releases before JBT 3.1.x.

                After that (current nightly buiilds) we add the DTP connection classpath to the classpath automatically.

                • 5. Re: Generating DDL from annotated POJOs
                  John Verhaeg Newbie

                  Okay, added the SQL Server jar to the Hibernate configuration, but still doesn't work. Now I don't even get the error log entry. But I think I stumbled onto an earlier indication that there's a classpath issue. In the Hibernate Configuration view, when I try to expand my configuration entry, I get a pop-up dialog saying the driver still can't be found. When I edit the config, I see the driver specified correctly in 2 places: Diving into the driver config via editing the "Database connection" entry, and also via my manual addition of that jar in the Classpath tab. Is there something else I'm missing? Also, is there some configuration I can attach that will help you to solve my problem?

                  • 6. Re: Generating DDL from annotated POJOs
                    Max Rydahl Andersen Master

                    Sounds to me you are still focusing on the classpath for the DTP connection and not for the configuration Hibernate Tools uses.

                    Pre-JBoss Tools 3.1.x you need to add the classpath to the console configuration or the related project.

                    Have you tried following the movies here: http://docs.jboss.org/tools/movies/

                    They (hopefully) explain how it works.



                    • 7. Re: Generating DDL from annotated POJOs
                      John Verhaeg Newbie

                      No, I'm not working with DTP at all. I've added the sqljdbc.jar to the Hibernate Console configuration classpath, the same type of configuration referenced in the video you pointed me to. I'm guessing there's probably something fundamentally wrong with my project due to the way I built it. My goal here was to start from a WSDL, then use the JAXWS tools built into JDK 1.6 to generate the respective POJOs from it, annotate those POJOs with JPA annotations (right along side the generated JAXB annotations), then generate DDL from these entities that I can use to build a representative view model in Teiid Designer. So, the only evidence in the project of things related to Hibernate/JPA is the @Entity tag on each of 2 classes and @GeneratedValue / @Id / @Column(name = "ID") for the id property I manually added to each. I don't have any entity resolvers, naming strategies, HibernateUtil classes, etc.

                      I also *sometimes* get compilation errors in this project (I haven't figured out the pattern yet for when these appear/disappear) related to those annotations in the form of "Column XXX cannot be resolved" for every property, where XXX is the property's name.

                      • 8. Re: Generating DDL from annotated POJOs
                        Max Rydahl Andersen Master

                        care to use jing or screenr to record what you are actually doing ? Might get us there faster than our current comment ping-pong ? :)

                        • 9. Re: Generating DDL from annotated POJOs
                          Max Rydahl Andersen Master

                          The screencast you sent to me in private email have the same error again and again on creating the console configuraiton:

                          Some class/package is missing and that is 99% because the project is not actually built. It also seems like there is no Entity class on the classpath.

                          Have you disabled automatic build ?

                          • 10. Re: Generating DDL from annotated POJOs
                            John Verhaeg Newbie

                            No, automatic build is turned on. Not to mention, I've tried manually building several times also with no change. Wrt the missing entity class, I show the Inner class in the screencast with the @Entity annotation, and I believe that is the class that can't be found for some reason. This is a bit of a new error for me. Not sure what I did right before the capture to get this. I was getting a ClassNotFoundException for the SqlServerDriver.

                            • 11. Re: Generating DDL from annotated POJOs
                              Max Rydahl Andersen Master

                              But the error is pretty clear here - the class you are referencing is not be found.

                              Either it is not in the build dir (which should be on the classpath), spelled incorrectly or referenced incorrectly (i.e. inner classes need a $ instead of . to be referenced)

                              • 12. Re: Generating DDL from annotated POJOs
                                John Verhaeg Newbie

                                Yes, the class is clearly missing from the bin folder as one would expect when seeing compilation errors for the class (The 'Column "XXX" cannot be resolved' errors I referred to before). So how do I get rid of those errors? What do I have configured incorrectly?

                                • 13. Re: Generating DDL from annotated POJOs
                                  Max Rydahl Andersen Master

                                  Those errors are not compilation errors; its Dali not being able to find the matching column/tables.

                                  They do not prevent generation of the .class.

                                  There must be something else wrong beyond Dali/JPA warnings/errors ?

                                  • 14. Re: Generating DDL from annotated POJOs
                                    John Verhaeg Newbie

                                    Here's an image of my errors. I don't see any other reason that the classes wouldn't be generated:

                                    http://screencast.com/t/aJJgvwU7

                                    1 2 Previous Next