Write manual in an entity the record id of a column that is lookup to another table

I have a table/entity “contacts” with an attribute “cnt_category” associated to another table “DLKP_CONTACT_CATEGORIES” with many to one relation and its lookup type is dropdown.

I am trying to migrate our old data. So i want to create a method in “contacts” entity to write manual the record id of a lookup in “DLKP_CONTACT_CATEGORIES”.

The existing method is
public void setCategory(DLKP_CONTACT_CATEGORIES category) {
this.category = category;
}

But i want an approach like this:
public void setCategory_RowID(long category_row_id){
this.category.id=category_row_id;
}

Thank you in advance

After a long night of experiments i found this solution.
In my entity i add this code:

public void setLookup_RowID(long category_row_id) {
DataManager dm;
try {
dm = AppBeans.get(DataManager.class);
category = dm.load(LoadContext.create(LOOKUP_TABLE.class).setId(category_row_id));
} catch (Exception ex) {
ex.printStackTrace();
} finally {
dm = null;
}
}

Also i created a service to get row id of a lookup from the old lookup table.

public long _getLookupId(DataManager dataManager, String lookup_table, String loockup_name, String lookup_code) {
StringBuilder sql = new StringBuilder();
long lookup_id = 0;
try {
sql.append(“select t.id from “).append(lookup_table).append(” t “);
sql.append(” where “);
if (loockup_name != null && !loockup_name.equals(””)) {
sql.append(" t.lkp_name = :lc_name and “);
}
sql.append(” t.lkp_code = :lc_code");

        if (loockup_name == null || loockup_name.equals("")) {
            lookup_id = dataManager.loadValue(sql.toString(), Long.class)
                    .parameter("lc_code", lookup_code)
                    .one();
        } else {
            lookup_id = dataManager.loadValue(sql.toString(), Long.class)
                    .parameter("lc_name", loockup_name)
                    .parameter("lc_code", lookup_code)
                    .one();
        }

    } catch (Exception ex) {
        Logging.error("getLookupId", ex);
    } finally {
        sql = null;
    }
    return lookup_id;
}

When you have an entity ID and want to use it to set a reference, use the DataManager.getReference() method:

Group group = dataManager.getReference(Group.class, groupId); // no database call here
user.setGroup(group);
dataManager.commit(user);