java - How can I access the mapping field directly whilst also having a relationship defined -


@entity @table(name="sometable_citylocation") public class citylocation extends model implements serializable {       private int citydestinationid;      @manytoone     @joincolumn(name="citydestinationid", referencedcolumnname="destinationid")     private city city; 

i have relationship, can cities easy mapping defined, need able set , alter citydestinationid directly because it's supplied me external source.

what annotations need able without losing functionality(getting cities object, being able set/alter/get id field/getters/setters)

exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'modeldao': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.hibernate.sessionfactory nl.exit.crunch.dao.abstractdao.sessionfactory; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'sessionfactory' defined in class path resource [nl/exit/crunch/config/hibernateconfiguration.class]: invocation of init method failed; nested exception org.hibernate.mappingexception: repeated column in mapping entity: nl.exit.crunch.table.some.destination.citylocation column: citydestinationid (should mapped insert="false" update="false")

the answer add insertable , updateable object mapping

@joincolumn(name="citydestinationid",             insertable=false,              updatable=false,              referencedcolumnname="destinationid"         ) 

keep in mind cannot use object bind/unbind relations. not relevant in case since foreign key supplied external source. care getting object out


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -