Is hibernate annotations supported in SDE for IntelliJ?

We have the SDE professional for Intellij and would like to use hibernate annotations to describe the mapping. Is this supported in SDE professional for IntelliJ?
http://www.hibernate.org/397.html

e.g., can it created annotations like this:

@Entity
public class Employer implements Serializable {
    @ManyToMany(
        targetEntity=org.hibernate.test.metadata.manytomany.Employee.class,
        cascade={CascadeType.PERSIST, CascadeType.MERGE}
    )
    @JoinTable(
        name="EMPLOYER_EMPLOYEE",
        joinColumns=@JoinColumn(name="EMPER_ID"),
        inverseJoinColumns=@JoinColumn(name="EMPEE_ID")
    )
    public Collection getEmployees() {
        return employees;
    }
    ...
}

Thanks,
Chris

Hi Chris,

Thank you for your post. You can find the option about annotation at Modeling > ORM > Generate Code…, in the dialog box, select “Annotation” in the drop-down menu of Mapping Type (you can refer to the attached image).

If you have any further inquiries, please feel free to ask.

Best regards,
Lilian Wong

select_annotation_in_mapping_type.png

While trying to generate code from my ORM diagram in Intellij 7.0, VP 3.2, I got this error message:

No message
java.lang.NullPointerException
at v.qqa.d(:246)
at v.tpe.d(:379)
at v.iww.fileDeleted(:47)
at com.intellij.openapi.vfs.newvfs.VirtualFileFilteringListener.fileDeleted(VirtualFileFilteringListener.java:81)
at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.PendingEventDispatcher.a(PendingEventDispatcher.java:55)
at com.intellij.util.PendingEventDispatcher.a(PendingEventDispatcher.java:13)
at com.intellij.util.PendingEventDispatcher.access$100(PendingEventDispatcher.java:42)
at com.intellij.util.PendingEventDispatcher$1.invoke(PendingEventDispatcher.java:5)
at $Proxy10.fileDeleted(Unknown Source)
at com.intellij.openapi.vfs.impl.VirtualFileManagerImpl.a(VirtualFileManagerImpl.java:38)
at com.intellij.openapi.vfs.impl.VirtualFileManagerImpl.access$200(VirtualFileManagerImpl.java:92)
at com.intellij.openapi.vfs.impl.VirtualFileManagerImpl$1.after(VirtualFileManagerImpl.java:1)
at sun.reflect.GeneratedMethodAccessor135.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:101)
at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:170)
at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:162)
at com.intellij.util.messages.impl.MessageBusImpl.access$000(MessageBusImpl.java:36)
at com.intellij.util.messages.impl.MessageBusImpl$2.invoke(MessageBusImpl.java:102)
at $Proxy72.after(Unknown Source)
at com.intellij.openapi.vfs.newvfs.persistent.PersistentFS.processEvents(PersistentFS.java:290)
at com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl$1$1$1.run(JarFileSystemImpl.java:1)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:141)
at com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl$1$1.run(JarFileSystemImpl.java:2)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:20)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:111)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:53)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:92)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

can you please help?

hvtranho

Thank you Lilian… That helped. I am now generating annotations for my ORM Persistable classes, although I notice that the annotations generated are very hibernate specific. Is there a way to specify VP to use standard JPA annotations?
http://java.sun.com/javaee/technologies/persistence.jsp

This way we can abstract our POJO objects from the underlying implementation? This way frameworks such as toplink, hibernate, etc all work with the POJO objects created.

Thanks,
Chris

p.s. I also get the same error the hvtranho reported, but it does seem to generate the code.

Right, the error message was not related to the problem of code generation. I did choose the wrong option: mapping code instead of POJO. Now I can generate java code with annotation.

It would be nice if only JPA classes are used for annotation.

Best regards,
hvtranho.

Hi Chris,

Thank you for your reply. We are sorry that we do not support JPA and we have no plan to support it at the moment.

If you have any inquiries, please feel free to ask.

Best regards,
Lilian Wong

I don’t understand the statement that you have no plans to support JPA. When I look at the generated code, I see annotations from the javax.persistence package. I also see hibernate annotations.

What part of JPA don’t you supprt? Would it be the java.persistence.spi?
Which JPA annotations/interfaces don’t you support?

Hi glm,

Thank you for you post. We indeed have no plan to support JPA, we only support hibernate notations which is using part of JPA.

If you have any further inquiries, please do not hesitate to ask.

Best regards,
Lilian Wong

Hi Lilian,

I don’t understand why you don’t plan to support JPA annotation generation??? :?:

I mean, to put it simple my point is this:

JPA is an accepted Standard in IT/JAVA community! I know a lot of projects that have chosen to develop their Entity-Layer like this, to be independent from the underlying ORM-Layer (Hibernate, Toplink…)
It would be great to have a tool like VP to support such a standard. If you can generate Hibernate Annotations, what is so difficult to write templates that support PLAIN JPA?? Maybe someone should take some time and read the EJB-JPA spec ( [java.sun.com/products/ejb/docs.html] ). This can’t be so hard… I myself develop a lot of projects using JPA and i have to do a lot of annotating by hand, as VP does not support it :cry:

I own a VP 6.1 Professional license. It would be great if you would change your minds an start developing JPA templates to give them to your paying customers. I even would pay for that kind of feature (to some extend).

Regards,
Martin

Hi Martin,

Thanks for your post. Since our ORM feature is based on Hibernate, which is extended from JPA.

In fact, you can draw EJB classes on Class Diagram, assign “ORM Persistent” as stereotype of the classes and synchronize them to ERD. After that, generate the code by Java round-trip engineering (available in VP-UML/SDE Professional Edition) will get the JPA annotations.

But VP-UML 6.1 may not support generate JPA annotation on Java round-trip engineering. I suggest you download the evaluation version of latest VP-UML from the Download site in our website ( http://www.visual-paradigm.com/download/download.jsp?product=vpsuite ) so that you can try out the feature.

If there is any further inquiry, please feel free to ask.

Best regards,
Lilian Wong