Discussions

News: Hibernate Annotations 3.0 Prev. Beta 1 / JBoss EJB 3.0 Preview 5

  1. The Hibernate 3.0 annotations project provides standalone EJB 3.0 annotation mappings for persistent objects. Some of the new features in this release include:
    • Mostly complete EDR2 support including default sensitive values of association mappings
    • Hibernate extensions: New Hibernate specific annotations to provide more mapping flexibility (caching strategy, type overriding...)
    • Better and more complete test suite and documentation
    Check out Hibernate's Annotation page for more information on downloading and documentation.

    JBoss EJB 3.0 provides an implementation of both the EJB and Persistence specifications of EDR2. New features in the release include:
    • Tight integration with Hibernate Annotations project
    • Application Transactions. Test out long-lived persistence contexts.
    • Hibernate 3.0 Integration. Mix and match EJB 3.0 annotated class files with .hbm.xml mapped class files all managed by EJB 3.0 EntityManager service. Get access to hibernate specific APIs.
    • Full clustering support.
    • Richer documentation set.


    Check out JBoss's EJB 3.0 site for details on documentation and downloading.

    Threaded Messages (14)

  2. I am using Hibernate annotations with one of my current OSS projects. So far I really like it, though a lot is (was?) still not implemented.

    Keep up the good job!

    Eelco Hillenius
  3. One the major features in Hibernate is the possibility to use different datasources just by switching the configuration hbm files. (exmpl MySql in develop modus en Oracle in production modus). Not a single change in the java source code!

    How would you achieve something similar with annotations?
  4. One the major features in Hibernate is the possibility to use different datasources just by switching the configuration hbm files. (exmpl MySql in develop modus en Oracle in production modus). Not a single change in the java source code!How would you achieve something similar with annotations?

    Hi Robin,
    Actually the annotations are focused on class mappings (ie an equivalent of MyClass.hbm.xml). You still have a hibernate.cfg.xml (or its API programmatic equivalent).
    Esp the dialect is still set the way you used to.
  5. Obfuscated code ! :-)[ Go to top ]

    Annotations can be really usefull but when your code looks like this (from Hibernate annotation documentation) :


    @Entity
    @BatchSize(size=5)
    @org.hibernate.annotations.Entity(
    selectBeforeUpdate = true,
    dynamicInsert = true, dynamicUpdate = true,
    optimisticLock = OptimisticLockType.ALL,
    polymorphism = PolymorphismType.EXPLICIT)
    @Where(clause="1=1")
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    @FilterDef(name="minLength", parameters={ @ParamDef( name="minLength", type="integer" ) } )
    @Filters( {
    @Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length"),
    @Filter(name="minLength", condition=":minLength <= length")
    } )
    public class Forest {


    it is more an obfuscated code ! :-((

    I love Hibernate but I'm not sure that I want to write such a code.
  6. Obfuscated code ! :-)[ Go to top ]

    This is the worst case in the whole test suite. Analyse it, it does not reflect real app code. Annotations has been designed to cover common cases the simpliest way... by not using annotations: if you want to refine the default scenario, you then start annotating your classes
    @Entity
    @BatchSize(size=5)
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    public class Forest {
       ...
    }

    This one is already complex enough in most cases.

    Honestly, there is already around 120 classes in the suite, I was too lazy to write another one, so I overused it :-)
  7. Obfuscated code ! :-)[ Go to top ]

    well then don't ... nobody said you have to. Perhaps others
    will refuse to work with your archaic xml based configuration .. but at least you had a choice.

    Incidentally the only reason that that is complex is because it is a complex configuration use case. Most things require one or zero lines of annotations.

    If you can't handle complex use cases .. again don't get involved with them.

    As Robert De Niro said in Ronin ....

    Your either part of the problem, the solution or the landscape.

    --b
  8. Well, this is how you do it programmatically:

    final AnnotationConfiguration cfg = new AnnotationConfiguration();

    // set configuration properties
    cfg.setProperty("hibernate.show_sql", "false");

    cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
    cfg.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
    cfg.setProperty("hibernate.connection.url", "jdbc:mysql://localhost/bwh");
    cfg.setProperty("hibernate.connection.username", "root");
    cfg.setProperty("hibernate.connection.password", "");

    // add persistent classes
    cfg.addAnnotatedClass(Address.class);
    cfg.addAnnotatedClass(Company.class);
    cfg.addAnnotatedClass(User.class);


    If you want to do that flexible, it's easy! just provide your properties in a more flexible way. Or... keep on using the hibernate configuration xml file.

    Eelco Hillenius
  9. mix/match[ Go to top ]

    Just so that you know, JBoss EJB3 supports mix/match of Hibernate mapped (.hbm.xml) and EJB3 annotated files in the same deployment. YOu can put your .hbm.xml files anywhere within the .ejb3 jar and they will get mapped and deployed. Hibernate/EJB3 can be managed by the same EntityManager interface.

    JBoss EJB3 support property file or cfg.xml format. In this file you have to define things like SQL dialect and such.
  10. Eclipse support[ Go to top ]

    Right, just had a look.

    Is there any kind of support for these annotations in Eclipse 3.1 or other IDEs? I couldn't get eclipse to eat these annotations, google was for once unhelpful to find me a plugin that could help.
  11. Eclipse support[ Go to top ]

    Right, just had a look.Is there any kind of support for these annotations in Eclipse 3.1 or other IDEs? I couldn't get eclipse to eat these annotations, google was for once unhelpful to find me a plugin that could help.

    Yes, if you use eclipse 3.1 M6, you get autocomplete and all that nice stuff ;)
  12. Eclipse support[ Go to top ]

    Yes, if you use eclipse 3.1 M6

    Bleeding edge indeed.

    (Syntax highlighting isn't an issue. Having eclipse want to compile my classes is)

    Thank you, will have another go now.
  13. Eclipse support[ Go to top ]

    Yes, if you use eclipse 3.1 M6
    Bleeding edge indeed.(Syntax highlighting isn't an issue. Having eclipse want to compile my classes is)Thank you, will have another go now.

    Putting the hibernate annotation jar to your buildpath might be useful
  14. Eclipse support[ Go to top ]

    Also enable the 5.0 compliance
  15. Eclipse support[ Go to top ]

    Putting the hibernate annotation jar to your buildpath might be useful

    You are right. However, that doesn't help squat if you are running eclipse 3.1M5, as I was.

    Still having problems building a toolchain that supports the stuff I need, though. I am missing several features, like Maps.

    Right now, the choice seems to either be to stick with jdk1.4 and xdoclet or to go for annotations and remodel without using Maps.