Search Results

Search found 5 results on 1 pages for 'eugenn'.

Page 1/1 | 1 

  • save the transient instance before flushing

    - by eugenn
    Exception: object references an unsaved transient instance - save the transient instance before flushing: Child How to reproduce issue: 1. Hibernate is load the entity "Parent". The property "child" is null 2. The "Parent" is rendered on the screen and after that the "child" property is auto instantiated. So I have the following graph: Parent.child != null Parent.child.childId = null Parent.child.childKey = "" Parent.child.childName = "" Question: How I could to force the Hibernate to ignore updating or inserting Child entity WHEN childId = null? If childId != null I would like just create relation. <hibernate-mapping> <class name="com.test.Parent" entity-name="ParentObject" table="parent" dynamic-insert="false" dynamic-update="true" optimistic-lock="version"> <id name="rowId" type="long"> <column name="RowID" /> <generator class="native" /> </id> <version name="versionSequence" type="integer" unsaved-value="null" generated="never" insert="false"> <column name="VersionSequence" /> </version> <many-to-one name="child" entity-name="Child" fetch="select" optimistic-lock="true" embed-xml="false" update="true" insert="false"> <column name="ChildID" /> </many-to-one> <property name="dateCreated" type="timestamp"> <column name="DateCreated" length="0" /> </property> <property name="dateUpdated" type="timestamp" update="false"> <column name="DateUpdated" length="0" /> </property> </class> </hibernate-mapping> <hibernate-mapping> <class name="com.Child" entity-name="Child" table="Child" dynamic-insert="false" dynamic-update="true" optimistic-lock="version"> <id name="childId" type="long" > <column name="ChildID" /> <generator class="native" /> </id> <version name="versionSequence" type="integer" insert="false" generated="never" > <column name="VersionSequence" /> </version> <property name="childKey" type="string" > <column name="ChildKey" length="20" /> </property> <property name="childName" type="string" > <column name="ChildName" length="30" /> </property> <property name="childNumber" type="string" > <column name="ChildNumber" /> </property> <property name="dateCreated" type="timestamp"> <column name="DateCreated" /> </property> <property name="dateUpdated" type="timestamp" update="false"> <column name="DateUpdated" /> </property> </class> </hibernate-mapping>

    Read the article

  • Why One-to-one relationship dosen't work?

    - by eugenn
    I'm trying to create a very simple relationship between two objects. Can anybody explain me why I can't find the Company object via findBy method? class Company { String name String desc City city static constraints = { city(unique: true) } } class City { String name static constraints = { } } class BootStrap { def init = { servletContext -> new City(name: 'Tokyo').save() new City(name: 'New York').save() new Company(name: 'company', city: City.findByName('New York')).save() def c = Company.findByName('company') // Why c=null????! } def destroy = { } }

    Read the article

  • maven multi-module versioning

    - by eugenn
    I have a multi-module project. parent POM (1.0-SNAPSHOT) |-- module1 (1.0-SNAPSHOT) |-- module2 (1.0-SNAPSHOT) `-- module3 (1.0-SNAPSHOT) When I execute mvn release:prepare it verify that parent POM has a SNAPSHOT version and all dependent modules don't have a SNAPSHOT version. How automatically update all child modules from SNAPSHOT to the next release version? I would like automatically increment version for all modules.

    Read the article

  • What the best way to convert from String to HashMap?

    - by eugenn
    I would like to serialize a Java HashMap to string representation. The HashMap will contains only primitive values like string and integer. After that this string will be stored to db. How to restore back the HashMap? Is it make sense to use BeanUtils and interface Converter or use JSON? For example: List list = new ArrayList(); list.add(new Long(1)); list.add(new Long(2)); list.add(new Long(4)); Map map = new HashMap(); map.put("cityId", new Integer(1)); map.put("name", "test"); map.put("float", new Float(-3.2)); map.put("ids", list); map.toString() -> {float=-3.2,ids=[1, 2, 4],name=test,cityId=1} map.toJSON -> {"float":-3.2,"ids":[1,2,4],"name":"test","cityId":1}

    Read the article

1