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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -