[Persistence, JBoss/CMP, Hibernate, Database] - Trying to cascade a delete operation
by lsToronto2009
I have a Company class:
| public class Company implements Serializable {
|
| ....
|
| @OneToMany (mappedBy="company", cascade=CascadeType.ALL)
| @JoinColumn(name="COMPANY_ID")
| private List<Address> addresses = new ArrayList<Address>();
| ...
| }
|
The intention is a company can have one to many addresses.
Here is the Address:
| public class Address implements Serializable {
| ....
|
| @ManyToOne
| private Company company;
|
| ...
| }
|
The behavior I want is if a Company is deleted, all the associated Addresses should be removed as well.
However when I delete a Company I get a constraint violation:
| com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`db`.`address`, CONSTRAINT `FK1ED033D44C674D5C` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`))
|
I thought the cascade=CascadeType.ALL in the Company class would give me this.
What am I doing wrong?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228062#4228062
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228062
15 years
[JBossWS] - Issue using XmlMixed, XmlRefrences, XmlRefrence annotations
by kyle.bober
I am having an issue with the XmlMixed, XmlRefrences, XmlRefrence annotations... Or so that is what I think is causing the issue.
I have a base class called CriteriaSO
| @XmlRootElement(name="Criteria")
| @XmlType(propOrder = {"sortType"})
| @XmlSeeAlso({IdCriteriaSO.class})
| public abstract class CriteriaSO {
|
| protected SortType theSortType;
|
| public CriteriaSO() {
| super();
| this.theSortType = KeywordAnalysisSortType.ASCENDING;
| }
|
| @XmlElement(name="SortType", required=true, nillable=false)
| public SortType getSortType() {
| return theSortType;
| }
|
| public void setSortType(SortType aSortType) {
| theSortType = aSortType;
| }
|
| }
|
I have a two classes that extend the CriteriaSO class ::
| @XmlRootElement(name="IdCriteria")
| @XmlType(propOrder = {"Ids"})
| public class IdCriteriaSO extends CriteriaSO {
|
| private static final long serialVersionUID = 20090430001L;
|
| private List<Integer> theIds;
|
| public IdCriteriaSO() {
| super(SortType.ASCENDING);
| this.theKeywordAnalysisIds = new ArrayList<Integer>();
| }
|
|
| @XmlElementWrapper(name = "Ids", nillable=false, required=true)
| @XmlElement(name = "Id", required = true, nillable = false)
| public List<Integer> getIds() {
| return theIds;
| }
|
| public void setIds(List<Integer> aIds) {
| theIds = aIds;
| }
| }
|
|
| @XmlRootElement(name="UserIdCriteria")
| @XmlType(propOrder = {"userIds"})
| public class UserIdCriteriaSO extends CriteriaSO {
|
| private static final long serialVersionUID = 20090430001L;
|
| private List<Integer> theUserIds;
|
| public UserIdCriteriaSO() {
| super(KeywordAnalysisSortType.ASCENDING);
| this.theUserIds = new ArrayList<Integer>();
| }
|
|
| @XmlElementWrapper(name = "userIds", nillable=false, required=true)
| @XmlElement(name = "userId", required = true, nillable = false)
| public List<Integer> getUserIds() {
| return theUserIds;
| }
|
| public void setUserIds(List<Integer> anUserIds) {
| theUserIds = anUserIds;
| }
| }
|
I then created a List wrapper to contain the CriteriaSO object instances like so ::
| @XmlRootElement(name="CriteriaList")
| @XmlSeeAlso({IdCriteriaSO.class, UserIdCriteriaSO.class})
| public class CriteriaListSO {
|
| private static final long serialVersionUID = 20090424001L;
|
| private List<CriteriaSO> theCriteria;
|
| public CriteriaListSO() {
| super();
| this.theCriteria = new ArrayList<KeywordAnalysisCriteriaSO>();
| }
|
|
| @XmlMixed
| @XmlElementRefs( {
| @XmlElementRef(name = "IdCriteria", type = IdCriteriaSO.class),
| @XmlElementRef(name = "UserIdCriteria", type = UserIdCriteriaSO.class) })
| public List<CriteriaSO> getCriteria() {
| return theCriteria;
| }
|
| public void setCriteria(List<sCriteriaSO> anCriteria) {
| theCriteria = anCriteria;
| }
| }
|
I have a web service method that takes a CriteriaListSO object as a parameter.
| @WebService(name="testService", serviceName="testService")
| @SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL, parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
| public class TestService {
|
|
| @WebMethod(operationName = "echoCriteria")
| @WebResult(name = "CriteriaList")
| @RequestWrapper(localName="echoCriteriaRequest")
| @ResponseWrapper(localName="echoCriteriaResponse")
| public CriteriaListSO echoCriteria(@WebParam(name = "CriteriaList")CriteriaListSO criteriaListSO) throws RemoteException {
|
| return criteriaListSO;
| }
| }
|
My issue is everytime I send a web service request to the echoCriteria web method with some CriteriaSO objects it doesn't set them in the CriteriaList object.
What I do see is one of the CriteriaList - ArrayList element's is being set to an object of type java.lang.String. And the contents of the String is the following
"\n" For each CriteriaSO object I add to the SOAP request it will add an additional \n to the string contents.
I am using JBoss 4.2.1
Any help or guidance would be appreciated. I have spent a few hours now on diffrent annotation configurations trying to figure this out.
-Kyle
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228054#4228054
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228054
15 years
[JBoss Tools (users)] - Re: Can't do anyting - please help
by krasig
Please execuse me. I post wrong log (I have another eclipse 64 bit installation with different errors)
This is correct log:
| !SESSION 2009-05-01 17:26:56.221 -----------------------------------------------
| eclipse.buildId=N20090426-1232
| java.version=1.5.0_15
| java.vendor=Sun Microsystems Inc.
| BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=bg_BG
| Command-line arguments: -os win32 -ws win32 -arch x86 -clean
|
| !ENTRY org.eclipse.osgi 2 1 2009-05-01 17:27:36.019
| !MESSAGE NLS unused message: facetNotDefined in: org.eclipse.wst.common.project.facet.core.internal.FacetedProject
|
| !ENTRY org.eclipse.osgi 2 1 2009-05-01 17:27:36.019
| !MESSAGE NLS unused message: facetVersionNotDefined in: org.eclipse.wst.common.project.facet.core.internal.FacetedProject
|
| !ENTRY org.jboss.tools.common.model 4 0 2009-05-01 17:27:41.910
| !MESSAGE Model feature org.jboss.tools.seam.internal.core.el.SeamPromptingProvider is not registered with extension point org.jboss.tools.common.model.classes
| !STACK 0
| java.lang.Exception: Model feature org.jboss.tools.seam.internal.core.el.SeamPromptingProvider is not registered with extension point org.jboss.tools.common.model.classes
| at org.jboss.tools.common.model.util.ModelFeatureFactory.createFeatureInstance(ModelFeatureFactory.java:74)
| at org.jboss.tools.jst.jsp.outline.ValueHelper.<clinit>(ValueHelper.java:74)
| at org.jboss.tools.jst.jsp.outline.JSPPropertySourceAdapter.<init>(JSPPropertySourceAdapter.java:66)
| at org.jboss.tools.jst.jsp.outline.JSPPropertySheetConfiguration$JSPPropertySourceProvider0.getPropertySource(JSPPropertySheetConfiguration.java:56)
| at org.eclipse.ui.views.properties.PropertySheetEntry.getPropertySource(PropertySheetEntry.java:470)
| at org.eclipse.ui.views.properties.PropertySheetEntry.setValues(PropertySheetEntry.java:752)
| at org.eclipse.ui.views.properties.PropertySheetViewer.setInput(PropertySheetViewer.java:973)
| at org.eclipse.ui.views.properties.PropertySheetPage.selectionChanged(PropertySheetPage.java:510)
| at org.eclipse.wst.sse.ui.internal.properties.ConfigurablePropertySheetPage.selectionChanged(ConfigurablePropertySheetPage.java:174)
| at org.eclipse.ui.views.properties.PropertySheet.selectionChanged(PropertySheet.java:361)
| at org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156)
| at org.eclipse.ui.internal.AbstractSelectionService.setActivePart(AbstractSelectionService.java:282)
| at org.eclipse.ui.internal.WorkbenchPagePartList.fireActivePartChanged(WorkbenchPagePartList.java:60)
| at org.eclipse.ui.internal.PartList.setActivePart(PartList.java:136)
| at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3528)
| at org.eclipse.ui.internal.WorkbenchPage.toggleFastView(WorkbenchPage.java:3872)
| at org.eclipse.ui.internal.ShowFastViewContribution.showView(ShowFastViewContribution.java:157)
| at org.eclipse.ui.internal.ShowFastViewContribution.access$1(ShowFastViewContribution.java:155)
| at org.eclipse.ui.internal.ShowFastViewContribution$3.widgetSelected(ShowFastViewContribution.java:138)
| at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
| at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
| at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
| at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
| at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
| at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
| at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
| at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
| at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
| at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
| at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
| at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
| at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
| at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
| at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
| at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
| at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
| at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
| at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
| at org.eclipse.equinox.launcher.Main.run(Main.java:1287)
| at org.eclipse.equinox.launcher.Main.main(Main.java:1263)
|
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228046#4228046
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228046
15 years