0

I'm trying to develop a library with generic classes to integrate into other projects. For example, a class representing interval:

@Data
public class Interval {
    private Instant start;
    private Instant end;
}

Since this library might be used by the projects that do not work with Hibernate / Spring, i would like not to include Hibernate dependency and its annotations.

Is there any way, from the perspective of a project using this library together with Hibernate, to make the class above Embeddable without subclassing it and annotating the child class myself ?

2 Answers 2

1

Well, for once, annotations are just annotations, so depending projects don't need a dependency on JPA/Hibernate to use the classes. The annotations will simply not be available if the annotation classes are not available.

Apart from that, you could also create an orm.xml file that provides the mapping information. Users of your library would then have to import that file.

Sign up to request clarification or add additional context in comments.

Comments

0

For later reference, creating custom types in Hibernate will be a great choice to make external library integratable into Hibernate-managed entities.

https://www.baeldung.com/hibernate-custom-types

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.