Results 1 to 1 of 1

Thread: DBLookups in ConversionService

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Location
    Aachen
    Posts
    1

    Default DBLookups in ConversionService

    Hi folks,

    I've got a design question about the ConversionService:

    I've got two Entities
    @Embeddable
    public class A {
    @Valid
    @ManyToOne(optional = false)
    private B b;
    private int alt;
    // getters/setter omitted
    }

    @Entity
    public class B {
    private Long id;
    String code;
    // getters/setter omitted
    }

    Additionally I've wrote a Parser,Printer,Formatter & add them to the ConversionService.

    At the moment I'm using the service to convert a String value into an instance of class A like this:

    A a = conversionService.convert("CC123", A.class);

    "CC" is the "code" field of class B (with must fulfill some RegExp) and
    123 is the value for field "alt" in class A


    Atm there is no database lookup to resolve "CC" with leads into that the field "id" is empty (only String value "CC" will be transfered)
    and I wanted to know if it is bad practise to build in any dependencies to database layer in the conversionService to resolve primary key for "CC"?



    Best regards,
    Claus
    Last edited by Texasranger; Dec 3rd, 2012 at 11:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •