Question

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?

Was it helpful?

Solution

You could use hyperjaxb:

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top