Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<jaxb:globalBindings> javaType causes @Transient #23

Open
mzdeb opened this issue Jun 18, 2015 · 2 comments
Open

<jaxb:globalBindings> javaType causes @Transient #23

mzdeb opened this issue Jun 18, 2015 · 2 comments
Assignees
Labels

Comments

@mzdeb
Copy link

mzdeb commented Jun 18, 2015

Firstly thank you for your hard work! :)

I want to map Joda Time classes (LocalDate, LocalDateTime etc.) to DB so I configured globalBindings:

<jaxb:globalBindings>
    <jaxb:javaType name="org.joda.time.LocalDateTime"
        xmlType="xsd:dateTime" parseMethod="org.joda.time.LocalDateTime.parse"
        printMethod="java.lang.String.valueOf" />
    <jaxb:javaType name="org.joda.time.LocalDate" xmlType="xsd:date"
        parseMethod="org.joda.time.LocalDate.parse" printMethod="java.lang.String.valueOf" />
</jaxb:globalBindings>

I've also annotated fields with Hibernate Type annotation like:

        <jaxb:bindings node="//*[@type='xsd:dateTime']"
            multiple="true">
            <annox:annotate target="getter">@org.hibernate.annotations.Type(type
                = "org.joda.time.contrib.hibernate.PersistentLocalDateTime")
            </annox:annotate>
        </jaxb:bindings>

Result is:

    @Transient
    @Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDateTime")
    public LocalDateTime getDate() {
        return date;
    }

As you can see @transient is undesirable here. I've found similar bug for previous Hyperjaxb realeases: http://jira.highsource.org/browse/HJIII-97 but it's still unresolved.

@highsource highsource added the bug label Jun 18, 2015
@highsource highsource added this to the 0.6.1 milestone Jun 18, 2015
@highsource highsource self-assigned this Jun 18, 2015
@mzdeb mzdeb changed the title <jaxb:globalBindings> causes @Transient <jaxb:globalBindings> javaType causes @Transient Jun 18, 2015
@highsource
Copy link
Owner

HJ3 adds @Transient as it assumes that the type of the property is not known to JPA. HJ3 can't also possibly know about all the types which are mappable with Hibernate. It also can't reason about annotations you add via Annox.

So, in core, @Transient isn't wrong here.

I see two ways to solve this:

  • Add a HJ3 feature to turn off @Transient for such cases.
  • Add a jaxb2-annotate-plugin feature to be able to remove a certain annotation.

I'd prefer the second option. It may feel a bit hacky, but it's not wrong in the scope of jaxb2-annotate-plugin and will produce expected results.

@mzdeb
Copy link
Author

mzdeb commented Jun 18, 2015

From my point of view both solutions are ok. If you prefer the second one it's fine with me.

@highsource highsource removed this from the 0.6.1 milestone Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants