Skip to main content

JAXB 2.0 and EJB 3.0

5 replies [Last post]
ibsscott
Offline
Joined: 2005-07-19

I was wondering if there is a way to use JAXB beans as EJB 3.0 Entity beans? ie add @Entity annotations, relationship mapping, table mapping, etc. It seems it would be ideal for use with JBoss EJB 3.0 and its Hibernate relational mapping.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ibsscott
Offline
Joined: 2005-07-19

To be more clear, is there a way to customize my own annotations, without making it part of the javadoc, such as this?

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "record")
@Inheritance(discriminatorValue="B")
@DiscriminatorColumn(name="record_type")
public class Record implements Serializable {
...
}

kohsuke
Offline
Joined: 2003-06-09

Nothing prevents you from putting both JAXB and EJB annotations on your code.

But if you are asking "shouldn't XJC have a mode where it generates additional EJB annotations on the generated Java beans?", then the answer would be "that would be a very nice plug-in for the RI!"

If someone is interested in writing it, please let us know, so that we can help you...

ibsscott
Offline
Joined: 2005-07-19

I'll give it a shot since I would like to use it. I'm not a very advanced programmer but it doesn't seem that complex from your blog.

ibsscott
Offline
Joined: 2005-07-19

Can the Code Injector sample handle what I want to do?

kohsuke
Offline
Joined: 2003-06-09

Cool!

I suggest we move the discussion to users@jaxb.dev.java.net or dev@jaxb.dev.java.net. You need to subscribe before you post, but it's much easier to use e-mails than this IMO (for example I can attach a file.)

The code injector isn't probably what you can use, because I don't think it lets you add annotations to the methods/fields JAXB produce.

I also just realized that Lexi, who is maintaining the hyperjaxb2 project, might be doing similar things. I'll ping him so that he can chime in.

Meanwhile, please consider subscribing to the dev or users alias in the JAXB project.