[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Problem with Discriminator Column
|
There seems to be a bug in the new inheritance processing, please log a bug
for this. The bug seems to be in InheritanceMetadata.process in the
subclass. Do you have the @Inheritance annotation in multiple classes in
the hierarchy.
As a workaround you can use a DescriptorCustomizer to call
descriptor.getInheritancePolicy().setClassIndicatorField(null) on the
ClassDescriptor for PersistentModuleLayoutForArrayBase and
PersistentModuleLayoutForArrayBase .
polvo wrote:
>
>
> James Sutherland wrote:
>>
>> [...]Is the Query using native SQL?
>> No.
>>
>> Please include your code/xml for the class and superclasses, and the code
>> for the Query.
>>
>> class:
>>
>> @Entity(name="SimpleModuleLayoutRect")
>> @DiscriminatorValue("SimpleModuleLayoutRect")
>> public class PersistentModuleLayoutForRectangularArrayBase extends
>> PersistentModuleLayoutForArrayBase {
>> @Embedded
>> @AttributeOverride(name="value",
>> column=@Column(name="NORTHSOUTHCLEARANCE"))
>> private LengthAmount northSouthClearance;
>>
>> @Embedded
>> @AttributeOverride(name="value",
>> column=@Column(name="EASTWESTCLEARANCE"))
>> private LengthAmount eastWestClearance;
>> [...]
>> }
>>
>> super
>> @Entity(name="SimpleModuleLayout")
>> public abstract class PersistentModuleLayoutForArrayBase extends
>> PersistentModuleLayout {
>> @ManyToOne
>> private PersistentModuleLayoutForArrayArea parent;
>>
>> String rowsAndPanels;
>>
>> String arrayBase;
>>
>> @JoinColumn(name="MODULERACKINGSYSTEM")
>> private ModuleRackingSystem moduleRackingSystem;
>>
>> @Embedded
>> @AttributeOverride(name="value",
>> column=@Column(name="EASTWESTSPACEBETWEENMODULES"))
>> private LengthAmount eastWestSpaceBetweenModules;
>>
>> @Embedded
>> @AttributeOverride(name="value",
>> column=@Column(name="NORTHSOUTHSPACEBETWEENPANELS"))
>> private LengthAmount northSouthSpaceBetweenPanels;
>>
>> private int numberOfGapsPerRow = 0;
>> [...]
>> }
>>
>> @Embedded
>> @AttributeOverride(name="value",
>> column=@Column(name="PANELGAPDISTANCE"))
>> private LengthAmount panelGapDistance;
>>
>> @ManyToOne
>> private Module module;
>>
>> super
>>
>> @Entity(name="ModuleLayout")
>> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
>> @DiscriminatorColumn(name="MODULELAYOUT_TYPE")
>> @Table(name="modulelayout")
>> public abstract class PersistentModuleLayout extends
>> PersistentDomainObject {
>>
>> @Id
>> @GeneratedValue(strategy=GenerationType.IDENTITY)
>> private Long id;
>>
>> @ManyToOne
>> PersistentArrayLayout arrayLayoutParent = null;
>> }
>>
>> It was likely this query in an abstract dao class that is wired with a
>> Spring-Eclipse Template bean:
>>
>> public T findWithId(Class<T> clazz, long id) {
>> return getJpaTemplate().find(clazz, id);
>> }
>>
>> or perhaps it was just a eclipse-generated query that resulted from a
>> call to arrayLayout.getModuleLayouts():
>>
>>
>> @OneToMany(mappedBy="arrayLayoutParent", cascade=CascadeType.ALL)
>> @OrderBy("id ASC")
>> List<PersistentModuleLayout> moduleLayouts;
>>
>>
>> As I mentioned before, this works fine in toplink essentials. After
>> encountering this issue yesterday, I reverted back to the toplink
>> essentials configuration and everything worked.
>>
>>
>> Separate issue: When I moved over eclipse link I needed to provide a name
>> for a db column that takes an Enum. The default column name in toplink
>> was MODULERACKINGSYSTEM. EclipseLink however insisted on looking for
>> MODULERACKINGSYSTEM_ID. Is this intended?
>>
>> @JoinColumn(name="MODULERACKINGSYSTEM")
>> private ModuleRackingSystem moduleRackingSystem;
>>
>>
>>
>> polvo wrote:
>>>
>>> I'm trying to move from toplink essentials to eclipselink and am having
>>> problems.
>>>
>>> I have a class in which I use the @DiscriminatorColumn annotation to
>>> specify a name other than "DTYPE"
>>>
>>> e.g.:
>>> @DiscriminatorColumn(name="MODULELAYOUT_TYPE")
>>>
>>> But instead of looking for a column named 'MODULELAYOUT_TYPE' instead of
>>> 'DTPYE' eclipseLink appears to be looking for both:
>>>
>>> Internal Exception:
>>> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown
>>> column 'DTYPE' in 'field list'
>>> Error Code: 1054
>>>
>>> Call: SELECT ID, MODULELAYOUT_TYPE, ARRAYLAYOUTPARENT_ID, ARRAYBASE,
>>> ROWSANDPANELS, NUMBEROFGAPSPERROW, PANELGAPDISTANCE,
>>> NORTHSOUTHSPACEBETWEENPANELS, EASTWESTSPACEBETWEENMODULES, MODULE_ID,
>>> PARENT_ID, MODULERACKINGSYSTEM, DTYPE, NORTHSOUTHCLEARANCE,
>>> EASTWESTCLEARANCE FROM modulelayout WHERE (ARRAYLAYOUTPARENT_ID = ?)
>>> ORDER BY ID ASC
>>> bind => [13]
>>>
>>> bug?
>>>
>>>
>>
>>
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Problem-with-Discriminator-Column-tp22799188p22826990.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.