-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: how to map a id which comes from a different table
PostPosted: Sun May 21, 2006 8:16 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
Hello,

I have a situation where I have a table that references another table:

(postgresql)

create table event (
eventId serial primary key,
eventType text
);

create table enforcement (
enforcementId integer references event primary key,
name text
);

What I would like to happen is when I save a new enforcement hibernate will create an event. Then the enforcement would reference the new event. Any suggestions on how I could map this? What I want essentially is to have the id for enforcement generated from the new event. What I'm thinking I can do is have:

<generator class="assigned">

but I don't see very much documentaion on this and was wondering if someone could shed some light on it. I'm open to other suggestions if that isn't the correct way of thinking of this problem.

thanks,
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 21, 2006 10:44 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Create a one-to-one from class Enforcement to class Event, with cascade at least "save" (cascade="all" might be better). In Event, use generator class="foreign".

This sets the id in the Event to be the same as the one in Enforcement, because Enforcement is the "primary" class. If you want to do it the other way around (create an Event, an Enforcement with the same id is generated) just move the one-to-one to Event and the foreign generator to Enforcement.

Afaik you can't have a foreign generator on the "main" class, like your question suggests. You can simulate it in java code though:
Code:
public void createNewEnforcement(Enforcement e)
{
  Event ev = new Event();
  ev.setEnforcement(e);
  session.save(ev); // generates ev's id, cascade-saves e with same id.
}
The API user thinks that the Enforcement is the "primary" class, but your DAO knows better.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 4:29 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
I should have explained this earlier. The other problem I face is I need the eventType to correspond to the table that references it. There are several other tables that reference the Event table for their primary key. Essentially, the event table is a sequence used by other tables.

So if I am inserting an Enforcement, then the Event table needs something like 'enforcement' for the eventType value.

Currently, we have the following working:

Code:
public void createNewEnforcement(Enforcement e)
{
  Event ev = new Event();
  ev.setEventType("enforcement");
  session.save(ev);
 
  e.setId( ev.getId() );
  session.save(e);
}


This works, but I feel that there might be a better way of doing it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 5:30 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
So you have a one-to-zero-or-one mapping from Event to those other tables, Enforcement included. If the java data model fits, I'd suggest using inheritence, probably the table-per-subclass-with-discriminator (refdocs section 10.1.3, in my version).

The idea would be to declare the Event mapping (not necessarily the java class) to be the superclass of the various other mappings (including Enforcement). Here's a stab at what it might look like.
Code:
<class name="Event" ...>
    <id name="id" type="integer" column="EVENT_ID">
        <generator class="native"/>
    </id>
    <discriminator column="EVENT_TYPE" type="integer"/>
    <property .../>
    ...

    <subclass name="Enforcement" discriminator-value="1">
        <join table="ENFORCEMENT">
            <key column="ENFORCEMENT_ID"/>
            <property .../>
            ...
        </join>
    </subclass>

    <subclass name="OtherEvent" discriminator-value="2">
        <join table="OTHER_TABLE">
            <key column="OTHER_ID"/>
            ...
        </join>
    </subclass>
</class>
Note that there's no requirement for the java Enforcement class to extend the Event class, though if Event has a few properties, then it might be a good idea to do that.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 2:09 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
Thanks for the information. That seems to be what I want to do, but I'm having problems. The mapping file:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.digitaldarwin.hibernate.model">
    <class name="Event" table="Event">
       
        <id name="id" column="eventId">
            <generator class="native">
                <param name="sequence">event_eventid_seq</param>
            </generator>
        </id>
       
        <discriminator column="eventType" type="string"/>
       
        <subclass name="Enforcement" discriminator-value="CREDIT">
            <join table="Enforcement">
                <key column="enforcementId"/>
                <property name="name" column="name"/>
            </join>
        </subclass>
    </class>
</hibernate-mapping>



I'm having a problem just reading the config file. I'm using maven2, but I don't think this is the problem. Although it could be. Assuming it's not, then i get the following error when I try to run my test for the dao. I can prevent this error by commenting out the

Code:
       <subclass name="Enforcement" discriminator-value="CREDIT">
            <join table="Enforcement">
                <key column="enforcementId"/>
                <property name="name" column="name"/>
            </join>
        </subclass>


But if I uncomment it out, then I get the following error:

Code:
OMITTED


Last edited by mmasters on Wed May 24, 2006 3:26 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 2:24 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
I can't believe I didn't try this before posting. If I have Enforcement extend Event, then it seems to work so far. I need to do some more testing, but at lease the file is being read now without any errors.

thanks,
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 3:33 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
Now I have another problem. I have another class which extends Event. This class is LicensePlate. LicensePlate has a composite id.

Code:
create table licensePlate (
    eventId integer references event,
    licensePlate text,
    vin text,
    primary key(eventId, licensePlate)
);


I've tried to map this using:

Code:
        <subclass name="LicensePlate" discriminator-value="licenseplate">
            <join table="LicensePlate">
                <key column="eventId"/>
                <composite-id>
                    <key-property name="eventId"/>
                    <key-property name="licensePlate"/>
                <composite-id>
                <property name="licensePlate"/>
                <property name="vin"/>
            </join>
        </subclass>


I've also tried:

Code:
        <subclass name="LicensePlate" discriminator-value="licenseplate">
            <join table="LicensePlate">
                <composite-id class="LicensePlateId">
                    <key-many-to-one name="eventId" class="Event" column="eventId"/>
                    <key-property name="licensePlate"/>
                <composite-id>
                <property name="vin"/>
            </join>
        </subclass>



Any suggestions on how I might be able to get this to work?

thanks for all the help!
Mike[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 5:49 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The key in the subclasses must be the same as the key in the superclass. There's a join performed on the columns, and you can't join two columns with one. If Event has only a single eventId PK, then LicensePlate's <key> mapping must mention only the column in the LicensePlate table that joins to Event's eventId column. You can map the text column as a property.

Are you certain that you want it to inhereit from Event? If the table has a two column PK, that suggests that there's several LicensePlates in a particular event (I dunno, a MultipleVehiclePileUpEvent, maybe?). If that's the case, then LicensePlate should be a collection in an Event, not an Event itself.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 10:03 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
So after discussing this with the dba, they are amenable to adding another table. I've attempted to create a collection of LicensePlates added to a LicensePlateSuspend object.

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.digitaldarwin.hibernate.model">
    <class name="LicensePlate" table="LicensePlate">

        <composite-id name="id" class="LicensePlate$Id" >
            <key-property name="licensePlateSuspendId"/>
            <key-property name="licensePlate"/>
        </composite-id>

        <property name="vin"/>

    </class>
</hibernate-mapping>




Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.digitaldarwin.hibernate.model">
    <class name="Event" table="Event">

        <id name="id" column="eventId">
            <generator class="native">
                <param name="sequence">event_eventid_seq</param>
            </generator>
        </id>   
           
        <discriminator column="eventType" type="string"/>

        <subclass name="Enforcement" discriminator-value="enforcement">
            <join table="Enforcement">
                <key column="eventId"/>
                <property name="name" column="name"/>
            </join>
        </subclass>
           
        <subclass name="LicensePlateSuspend" discriminator-value="license plate suspend">
            <join table="LicensePlateSuspend">
                <key column="licensePlateSuspendId"/>
                <set name="licensePlates">
                    <key>
                        <column name="licensePlateSuspendId" />
                        <column name="licensePlate" />
                    </key>
                    <one-to-many class="LicensePlate"/>
                </set>
            </join>
        </subclass>
           
    </class>
</hibernate-mapping>



For some reason I get a org.hibernate.MappingException with the above Event.hbm.xml. If I comment out the

Code:
               <set name="licensePlates">
                    <key>
                        <column name="licensePlateSuspendId" />
                        <column name="licensePlate" />
                    </key>
                    <one-to-many class="LicensePlate"/>
                </set>



then it will at least read the file without any errors. I am using the following database:

Code:
create table event (
    eventId serial primary key,
    eventType text
);

create table enforcement (
    eventId integer references event primary key,
    name text
);

create table licensePlateSuspend (
    licensePlateSuspendId integer references event primary key
);

create table licensePlate (
    licensePlateSuspendId integer references licensePlateSuspend,
    licensePlate text,
    vin text,
    primary key(licensePlateSuspendId, licensePlate)
);


Unfortunantly they are unwilling to remove the composite key on licensePlate.

Anyone have any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 10:17 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Just because a database index is composite doesn't mean that the <key> or <id> in your mapping has to have two properties.

Your problem is that you have a one-to-many in which the many-side (LicensePlate) has two columns in its key, one being the PK of the table on the one side (Event), and one being a key specific to the many-table. If that second part of LicensePlate's key is unique (as opposed to unique per Event) then there's no problems: just pretend in your mapping that the second part of the key is the <id>, and use the first part only for the many-to-one back to the Event object.

If the second part of the key is not unique (you can have keys (EventA,License1) and (EventB,License1)) then you have to use a composite-id. This is quite common, so the good people at Hibernate Central have provided you with a comprehensive example on how to do it in section 23.4.2, "Composite key example", of the ref docs. They use <list> and <bag>, but exactly the same thing applies to <set>.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 11:02 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
I've been referencing section 23.4.2. Composite key example, but I can't seem to get it to work. I am in the situation where the second column is not unique. (event1, abc) and (event2, abc) can both exist. I can read LicensePlate.hbm.xml without any errors, but Event.hbm.xml is having problems. I've tried using a bag as the example uses, but this causes problems.

Code:
        <subclass name="LicensePlateSuspend" discriminator-value="license plate suspend">
            <join table="LicensePlateSuspend">

                <key column="licensePlateSuspendId"/>

                <bag name="licensePlates">
                    <key>
                        <column name="licensePlateSuspendId"/>
                        <column name="licensePlate"/>
                    </key>
                    <one-to-many class="LicensePlate"/>
                </bag>
            </join>
        </subclass>



I would think this would at least read without problems, but I keep getting a MappingException.

any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 11:08 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You should be able to use bag and set interchangably.. though max did post only a couple of days ago about a known bug in bag mappings. I've completely forgotten what it is, though.

Can you post the MappingException, along with any and all Caused By clauses? The mapping you've posted looks fine.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 11:16 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
Aaaaaaaaargh!!!

I can't believe I didn't see this earlier!

Code:
junit.framework.AssertionFailedError: Exception in constructor: testDao (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [dd-hibernate-data.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not read mapping document from file: /Users/mmasters/Home/dd-hibernate/target/classes/com/digitaldarwin/hibernate/model/Event.hbm.xml
Caused by: org.hibernate.MappingException: Could not read mapping document from file: /Users/mmasters/Home/dd-hibernate/target/classes/com/digitaldarwin/hibernate/model/Event.hbm.xml
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:270)
        at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:583)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:729)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:877)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:846)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:419)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:152)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:247)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:331)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
        at com.digitaldarwin.hibernate.dao.BaseDaoTestCase.<init>(BaseDaoTestCase.java:14)
        at com.digitaldarwin.hibernate.dao.EnforcementDaoTest.<init>(EnforcementDaoTest.java:6)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at junit.framework.TestSuite.createTest(TestSuite.java:131)
        at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
        at junit.framework.TestSuite.<init>(TestSuite.java:75)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at org.apache.maven.surefire.battery.JUnitBattery.processTestClass(JUnitBattery.java:145)
        at org.apache.maven.surefire.battery.JUnitBattery.<init>(JUnitBattery.java:81)
        at org.apache.maven.surefire.SurefireUtils.instantiateBattery(SurefireUtils.java:63)
        at org.apache.maven.surefire.Surefire.instantiateBatteries(Surefire.java:262)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:140)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:87)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:285)
        at org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:201)
        at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:366)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.hibernate.MappingException: invalid mapping
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425)
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:267)
        ... 55 more
Caused by: org.xml.sax.SAXParseException: Element "join" does not allow "set" here.
        at org.apache.crimson.parser.Parser2.error(Parser2.java:3354)
        at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:349)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1497)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
        ... 56 more
)
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.TestSuite$1.runTest(TestSuite.java:263)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.maven.surefire.battery.JUnitBattery.executeJUnit(JUnitBattery.java:242)
        at org.apache.maven.surefire.battery.JUnitBattery.execute(JUnitBattery.java:216)
        at org.apache.maven.surefire.Surefire.executeBattery(Surefire.java:215)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:163)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:87)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:285)
        at org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:201)
        at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:366)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)



looks like I can't have a set tag or a bag tag inside of a join tag. Any way I can get around this?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 11:53 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Ouch. Well, there are two options that I can think of:

1) Put a component in the <join>, as components can have sets. This means you'll have stuff like "lpSuspend.getComponent().getLicensePlates()" in your java code, but you can hide that by using delegation.

2) Switch to using <joined-subclass> instead of <subclass><join>. This one has more serious ramifications: you'll have to do some refactoring. But it should work, and probably more elegantly than option 1.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 11:59 pm 
Regular
Regular

Joined: Mon Jun 13, 2005 12:38 pm
Posts: 56
Location: Austin, TX
tenwit wrote:
Ouch. Well, there are two options that I can think of:

1) Put a component in the <join>, as components can have sets. This means you'll have stuff like "lpSuspend.getComponent().getLicensePlates()" in your java code, but you can hide that by using delegation.

2) Switch to using <joined-subclass> instead of <subclass><join>. This one has more serious ramifications: you'll have to do some refactoring. But it should work, and probably more elegantly than option 1.


1. How can I do this using delegation? What is delegation? I don't see it in the ref doc.

2. I tried using <joined-subclass> but I can't use a discriminator.


any chance you use IRC? I've been on the hibernate channel but noone seems to be there :)

thanks for all the help,
Mike


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.