Hi,

Can you share the features you have installed about jpa ?

Regards
JB

> Le 28 févr. 2020 à 15:38, Erdbeerheld1990 <andreas-van-hel...@gmx.de> a écrit 
> :
> 
> Hello,
> 
> we are using karaf version 4.2.7 with blueprint. Now the first time we want
> to implement an  Attribute Converter
> <https://www.baeldung.com/jpa-attribute-converters>   from JPA in order to
> convert the string content of a column to an Object. 
> 
> @Converter(autoApply = true)
> public class DynamicViewConfigurationConverterJson implements
> AttributeConverter<DynamicViewConfiguration, String> {
> 
>  private final static ObjectMapper objectMapper = new ObjectMapper();
> 
>  @Override
>  public String convertToDatabaseColumn(DynamicViewConfiguration
> dynamicViewConfiguration) {
>    try {
>      return objectMapper.writeValueAsString(dynamicViewConfiguration);
>    } catch (JsonProcessingException ex) {
>      return null;
>    }
>  }
> 
>  @Override
>  public DynamicViewConfiguration convertToEntityAttribute(String dbData) {
>    try {
>      return objectMapper.readValue(dbData, DynamicViewConfiguration.class);
>    } catch (IOException e) {
>      throw new RuntimeException(e);
>    }
>  }
> 
> } 
> 
> And this is my entity:
> 
> @Entity
> @Table(name = "CAIS_DYNAMIC_VIEW")
> public class DynamicView {
>  private Long id;
>  private String viewName;
>  private String detailViewRoute;
>  private String translationKey;
>  private String viewCategory;
>  private DynamicViewConfiguration viewConfiguration;
> 
>  public DynamicView() {
>  }
> 
>  @Id
>  @GenericGenerator(name = "id_generator", strategy =
> "com.cedros.cais.persistence.generator.IdGenerator")
>  @GeneratedValue(generator = "id_generator")
>  public Long getId() {
>    return id;
>  }
> 
>  public void setId(Long id) {
>    this.id = id;
>  }
> 
>  @Column(name = "VIEW_NAME", nullable = false)
>  public String getViewName() {
>    return viewName;
>  }
> 
>  public void setViewName(String viewName) {
>    this.viewName = viewName;
>  }
> 
>  @Column(name = "DETAIL_VIEW_ROUTE")
>  public String getDetailViewRoute() {
>    return detailViewRoute;
>  }
> 
>  public void setDetailViewRoute(String detailViewRoute) {
>    this.detailViewRoute = detailViewRoute;
>  }
> 
>  @Column(name = "TRANSLATION_KEY", nullable = false)
>  public String getTranslationKey() {
>    return translationKey;
>  }
> 
>  public void setTranslationKey(String translationKey) {
>    this.translationKey = translationKey;
>  }
> 
>  @Column(name = "VIEW_CATEGORY")
>  public String getViewCategory() {
>    return viewCategory;
>  }
> 
>  public void setViewCategory(String viewCategory) {
>    this.viewCategory = viewCategory;
>  }
> 
>  @Column(name = "VIEW_CONFIGURATION", nullable = false)
>  @Convert( converter = DynamicViewConfigurationConverterJson.class)
>  public DynamicViewConfiguration getViewConfiguration() {
>    return viewConfiguration;
>  }
> 
>  public void setViewConfiguration(DynamicViewConfiguration
> viewConfiguration) {
>    this.viewConfiguration = viewConfiguration;
>  }
> }
> 
> 
> My Unit tests are working fine from spring context. But when i keep the
> @Convert annotation and run it in karaf, my DAOs are not starting. They are
> waiting for the persistence-Context and fail after some time - Declaritive
> Services:
> 
> Status: GracePeriod
> Blueprint
> 28.02.20 15:30
> Missing dependencies:
> (&(osgi.unit.name=caisPersistenceUnit)(objectClass=javax.persistence.EntityManager))
> Declarative Services
> 
> 
> When i remove the @Convert annotation it is not complaining, but then of
> course my attribute converter has not any effect. I would be very pleased
> for your help.
> 
> Best regards,
> Andreas
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply via email to