Pedro Araujo
Pedro Araujo

Reputation: 57

How to generate @OneToOne and @ManyToMany JPA relations in Telosys using Dsl Model

Im trying to generate classes using my own springboot template and Dsl models. In my ".entity" files I have:

Car {​​​​​
id : int {​​​​​ @Id, @AutoIncremented }​​​​​;
users : Employee [];
}​​​​​
    
Employee {​​​​​
id : long {​​​​​ @Id }​​​​​ ;
name : string ;
cars : Car[] ;
}​​​​​

I was expecting a @ManyToMany relation in JPA but I didn't. The same thing with this:

Car {​​​​​
id : int {​​​​​ @Id, @AutoIncremented }​​​​​;
user : Employee;
}​​​​​
    
Employee {​​​​​
id : long {​​​​​ @Id }​​​​​ ;
name : string ;
car : Car;
}​​​​​

I expect a @OneToOne relation but I don't get it. It seems I can only get @ManyToOne and @OneToMany. How can I get @ManyToMany and @OneToOne relations using DSL models?

Upvotes: 2

Views: 233

Answers (1)

lgu
lgu

Reputation: 2460

Since Telosys 3.3.0 you can do that with “@OneToOne” and “@ManyToMany” DSL model annotations.

Add annotation for the relevant link, for example :

MyEntity {
  ...
  employee : Employee  { @OneToOne   @FetchTypeLazy  } ; 
  projects : Project[] { @ManyToMany @LinkByJoinEntity(EmpProj) } ;
}

See the doc :

Upvotes: 1

Related Questions