package org.ng200.openolympus.services;

import org.jooq.DSLContext;
import org.jooq.impl.TableImpl;
import org.jooq.impl.UpdatableRecordImpl;
import org.springframework.beans.factory.annotation.Autowired;

import com.google.common.base.Throwables;

public abstract class GenericCreateUpdateRepository {

	@Autowired
	private DSLContext dslContext;

	@SuppressWarnings("unchecked")
	protected <T, R extends UpdatableRecordImpl<?>> T insert(T value,
			TableImpl<R> table) {
		try {
			R record;
			record = table.getRecordType().newInstance();
			record.attach(dslContext.configuration());
			record.from(value);
			record.store();
			record.refresh();
			return (T) record.into(value.getClass());
		} catch (InstantiationException | IllegalAccessException e) {
			throw Throwables.propagate(e);
		}
	}

	@SuppressWarnings("unchecked")
	protected <T, R extends UpdatableRecordImpl<?>> T update(T value,
			TableImpl<R> table) {
		try {
			R record;
			record = table.getRecordType().newInstance();
			record.attach(dslContext.configuration());
			record.from(value);
			return (T) dslContext.update(table).set(record).returning()
					.fetchOne().into(value.getClass());
		} catch (InstantiationException | IllegalAccessException e) {
			throw Throwables.propagate(e);
		}
	}

}

@@ -132,24 +132,81 @@
 RecordImpl;%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import org.s
@@ -256,16 +256,16 @@
 owired;%0A
-
 %0Aimport 
@@ -400,16 +400,121 @@
 ntext;%0A%0A
+%09private static final Logger logger = LoggerFactory%0A%09%09%09.getLogger(GenericCreateUpdateRepository.class);%0A%0A
 %09@Suppre
@@ -791,29 +791,8 @@
 ();%0A
-%09%09%09record.refresh();%0A
 %09%09%09r
@@ -1210,82 +1210,43 @@
 %09%09re
-turn (T) dslContext.update(table).set(record).returning()%0A%09%09%09%09%09.fetchOne()
+cord.update();%0A%09%09%09return (T) record
 .int

Fix CRUD