[hibernate-dev] Java 6, 7 and 8... oh my!

Steve Ebersole steve at hibernate.org
Wed Apr 1 07:32:36 EDT 2015


Sorry, wrong class...  XmlElementRef, not XmlElement:

/home/sebersole/projects/hibernate/hibernate-orm/hibernate-core/target/generated-src/jaxb/main/org/hibernate/boot/jaxb/hbm/spi/JaxbHbmFilterType.java:57:
error: cannot find symbol
    @XmlElementRef(name = "aliases", namespace = "
http://www.hibernate.org/xsd/orm/hbm", type = JAXBElement.class, required =
false)

                                                  ^
  symbol:   method required()
  location: @interface XmlElementRef


If we decide to stick with support for Java 6, I will try to incorporate
this -target option.  Thanks!



On Wed, Apr 1, 2015 at 1:55 AM, Gunnar Morling <gunnar at hibernate.org> wrote:

> Hi,
>
> Can you share the exact exception/error you get when using the generated
> model with Java 6? The required() attribute already exists as of Java 6 [1].
>
> You should be able to make the generated code Java 6 compatible by either
> setting the right options for XJC (the JAXB code generator) or in the worst
> case by falling back to an older version of XJC. I had a quick look, this
> setting looks promising:
>
>     -target (2.0|2.1): Avoid generating code that relies on any JAXB
> 2.1|2.2 features. This will allow the generated code to run with JAXB 2.0
> runtime (such as JavaSE 6.)
>
> That being said, I think it'd be fine to require Java 7 for ORM 5. OGM,
> Search and also many other libraries have done that move by now.
>
> --Gunnar
>
> [1]
> http://docs.oracle.com/javase/6/docs/api/javax/xml/bind/annotation/XmlElement.html#required()
>
>
>
> 2015-04-01 2:04 GMT+02:00 Steve Ebersole <steve at hibernate.org>:
>
>> So we now have to deal with a multi-jdk build in Hibernate ORM.  We need
>> Java 8 in order to compile the new hibernate-java8 module.
>>
>> I wanted to remain compatible with Java 6 for the rest.  However, I ran
>> into a snag there because of JAXB which we now use (in conjunction with
>> StAX) to process XML in ORM.  ANyway, the JAX generation creates a model
>> that is only compatible with Java 7.  I have not yet had time to
>> investigate this deeply.  But it has to do with a change in the definition
>> of javax.xml.bind.annotation.XmlElement and a change in its definition
>> between 1.6 and 1.7 to add a new
>> attribute javax.xml.bind.annotation.XmlElement#required.
>>
>> If anyone is familiar with this situation, I'd love to hear some options
>> before I spend a lot of time investigating it.
>>
>> The other option is that we say we are going to drop Java 6 support since
>> it has been unsupported now for, what, 3 years?
>> _______________________________________________
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>
>


More information about the hibernate-dev mailing list