Pregunta

I would like to ask such question, I have XML xsd`s, which generate beans with org.jvnet.jaxb2.maven2 , but now I need to add to these beans java.persistence mapping.

Which is the best way?

here is example of xsd:

...
<xs:element name="incomeCheck" type="xs:boolean"/>
<xs:element name="incomeAmount" type="xs:decimal"/>
<xs:element name="outcomeCheck" type="xs:boolean"/>
...

and here what it generates:

public class serviceData
    implements Serializable, Equals
{
...
protected boolean incomeCheck;
@XmlElement(required = true)
protected BigDecimal incomeAmount;
protected boolean outcomeCheck;
@XmlElement(required = true)
...

and I need that it would generate something like this:

@Entity
@Table(name="serviceData")
public class serviceData
    implements Serializable, Equals
{
...
@Column(name="incomeCheck")
protected boolean incomeCheck;
@XmlElement(required = true)
@Column(name="incomeAmount")
protected BigDecimal incomeAmount;
@Column(name="outcomeCheck")
protected boolean outcomeCheck;
@XmlElement(required = true)
...

To extend my question: As we figured out, we can use HyperJaxb, but can someone tell how to configure pom file, so it would generate these annotations?

¿Fue útil?

Solución

You could use hyperjaxb:

Otros consejos

I don't think you can achieve that. I think the only approach would be to generate your beans and then annotate them for persistence, but this way you'll have to maintain both your beans and your xsd manually.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top