Hello,

2013/10/9 Daniele Antonini <[email protected]>

> Hi, I’m using Jooq with model mapper and guice in a quite big application.
> I’using model Jooq 3.1.0, mapper 0.6.1 and guice 3.0.
>
>
> I followed instructions I find 
> here<http://blog.jooq.org/2013/08/06/use-modelmapper-and-jooq-to-regain-control-of-your-domain-model/>
>  but
> the following test fails:
>
>
> class MiaClasse {
>   private String asd; //used to force custome property mapping
>   private String email;
>   //get and set here ….
> }
>
>
> @Test
> public void jooqRecordModelMapperTest() throws Exception {
>   Result<Record2> res = JooqUtil.getDSLContext(db.getConnection())
>     .select(ACCOUNT_USER.PASSWORD_HASH, ACCOUNT_USER.EMAIL)
>     .from(ACCOUNT_USER)
>     .fetch();
>   ModelMapper mp = new ModelMapper();
>   mp.getConfiguration().addValueReader(new RecordValueReader());
>   mp.getConfiguration().setSourceNameTokenizer(NameTokenizers.UNDERSCORE);
>   mp.getConfiguration().setProvider(GuiceIntegration.fromGuice(injector));
>   mp.addMappings(new PropertyMap() {
>     @Override
>     protected void configure() {
>       map(source(“password_hash”)).setAsd(null);
>     }
>   });
>   for (Record2 r : res) {
>     MiaClasse c = mp.map(r, MiaClasse.class);
>     assertThat(c.getAsd(), is(r.value1()));
>     assertThat(c.getEmail(), is(r.value2()));
>   }
> }
>
>
> to get it pass i need to use a PropertyMap instead of PropertyMap.
>

I'm not sure what you mean by this.

> But in Jooq 3.1.0 RecordImpl class is a package protected, so I need to
> “patch” it including this one in my source code tree and set the public
> visibility.
>

Why do you need to patch RecordImpl? I don't see this from your example,
above...

> Can you make this class public?
>
> Nope :-)
Most classes in the org.jooq.impl package are package-private for a good
reason. I do not want to maintain an internal API through semantic
versioning.

You can create a record (which is in fact a RecordImpl) using
DSLContext.newRecord():
http://www.jooq.org/javadoc/latest/org/jooq/DSLContext.html#newRecord(org.jooq.Table)

Cheers
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to