@Table(name="parent")
class Parent {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
private Set<Child> attachments = new HashSet<Child>();
.....
}
@Entity
@Table(name="child)
class Child {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "parent_id", nullable = false)
private Parent parent;
...
}
@Entity @Mapper(componentModel = "spring", uses = CustomMapper.class)
public interface MyObjectMapper {
@Mappings({
@Mapping(target = "field", expression = "java(customMapper.convert(obj.field, lang))"
})
DTO map(Entity obj, Language lang);
}
componentModel = "spring"
, но и удалить поле имеющее INSTANCE, иначе @Autowired не будет подставлять реализацию....
CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );
...
package by.psu.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class ViewController {
@RequestMapping(value = "/**/{[path:[^\\.]*}")
public String redirect() {
return "forward:/";
}
}