|
Re: [CDO/Hibernate] Defining not-nullable EReferences [message #900417 is a reply to message #899992] |
Mon, 06 August 2012 23:29 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Christophe,
Sorry for the later answer, I did a testcase and issue for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386607
After the next build the name attribute is not needed anymore.
For your specific issue, set nullable="true" will help (I should have seen that right away...).
gr. Martin
On 08/03/2012 01:27 PM, Christoph Keimel wrote:
> Hello
>
> I am creating a demo with CDO/Hibernate to see if all our requirements in the generated database tables can be met. So
> far I am doing well except for two small issues I ran into with EReferences that should be set to "not null" in the
> database.
>
> To achieve this I tried to set the annotations via xml like this:
> <eclass name="Assignment">
> ...
> <ereference name="project">
> <join-column name="project_e_id" nullable="false"/>
> </ereference>
> ...
> </eclass>
> The "nullable" attribute seems to be ignored.
> (I'm sure the file is read correctly, because other constraints on attributes work: i.e. <column nullable="false"
> unique="true"/>).
>
> Environment:
> - CDO 4.1.0.v20120612
> - TENEO 2.0.0.v20120709
> - MySQL Server 5.5.18
>
> Related, but different: If the name attribute is omitted in the join-column element this will lead to an exception:
>
> [ERROR] Unable to read XML
> org.hibernate.InvalidMappingException: Unable to read XML
> at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:106)
> at org.hibernate.cfg.Configuration.add(Configuration.java:477)
> ...
>
> Caused by: org.xml.sax.SAXParseException: Attribute "name" is required and must be specified for element type "column".
> at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
> at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
> This is only the case for join-column elements and not for column elements. This should not be required imho.
>
> Would you like bug reports on these issues, or am I missing something?
>
> Greetings
> Christoph
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
|
Re: [CDO/Hibernate] Defining not-nullable EReferences [message #900637 is a reply to message #900543] |
Tue, 07 August 2012 21:30 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Christophe,
I asked Ed Merks to reply on your question.
Regarding the persistence xml, instead of setting the nullable on the join column you have to use a many-to-one tag in
this case (the many-to-one again overrides the join-column one, bit unlogical but that's the way it works now...).
Like here:
<?xml version="1.0" encoding="utf-8"?>
<persistence-mapping xmlns="http://www.eclipse.org/emft/teneo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<epackage namespace-uri="http://www.eclipse.org/emf/teneo/samples/issues/bz386607">
<eclass name="Bar">
<ereference name="foo">
<many-to-one optional="false"/>
</ereference>
</eclass>
</epackage>
</persistence-mapping>
gr. Martin
On 08/07/2012 03:12 PM, Christoph Keimel wrote:
> Hi Martin,
>
> I'm using xcore to define the model. I. e.:
> class Project extends CompanyElement {
> refers Assignment[] assignements opposite project
> }
>
> class Assignment {
> refers Project project opposite assignements
> refers Employee employee opposite assignements
> }
> I also tried "refers Project[1] project", to make it mandatory, but that did not have an effect on the column definition
> (nor on the generated classes). Is there another way to define mandatory attributes/references in ecore/xcore?
>
> Greetings
> Christoph
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Powered by
FUDForum. Page generated in 0.03905 seconds