Hibernate mapping composite-id

I have a table which has a primary key with two elements. My hibernate-tools plugin in Eclipse generated the mapping file with a composite-id
which maps to a class with those two parameters. But hibernate gives me: "org.hibernate.MappingException: component class not found: CountrylanguageId"
How can I get hibernate to see this class ?

Did you create the CountrylanguageId java class?

Similar Messages

  • Problem in hibernate mapping

    I am new to hibernate and found some problem in mapping for a simple example. Kindly have a look at my code and stack trace and help me fix the problem.
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
         <class name="com.mindtree.entity.MobileInvoice" table="MOBILE">
              <property name="model" column="MODEL"/>
              <property name="make" column="MAKE"/>
              <property name="price" column="PRICE"/>
              <property name="date" column="DATE1" />
              <property name="csex" column="CSEX" />
              <property name="cage" column= "CAGE" />
              <id name="id" column="ID">
                   <generator class="increment"/>
    org.hibernate.MappingException: Could not read mappings from resource: Mobile.hbm.xml
         at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
         at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
         at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
         at com.mindtree.dao.MobileDAOImpl.addInvoice(MobileDAOImpl.java:25)
         at com.mindtree.dao.Test.main(Test.java:18)
    Caused by: org.hibernate.MappingException: invalid mapping
         at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425)
         at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
         ... 8 more
    Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
         at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
         at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
         at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
         at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
         at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.dom4j.io.SAXReader.read(SAXReader.java:465)
         at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
         ... 9 moreThanks :)

    for ex:
    <mapping resource="com/spm/dao/Login.hbm.xml" />
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
         <class name="com.dao.Login" table="login">
              <id name="id" type="java.lang.Short">
                   <column name="id" />
                   <generator class="increment" />
              <property name="username" type="java.lang.String">
                   <column name="username" length="15" not-null="true" />

  • Hibernate Mapping Exception Error reading resource: Help Please

    I've downloaded Hibernate this weekend and have been working at getting this up and running in my spare time. I've run into a problem and can't seem to find the solution. I'm hoping some one here can help me out.
    I'm running MyEclipse
    and Hibernate 2 in a struts application
    I've only got one form and table that I'm trying to map right now, but I get the above error when I run this line of code.
    Configuration cfg = new Configuration().addClass(AddCustomerForm.class);
    Does anyone have any ideas. Here are the important sections from the two configuration files
    <!-- hibernate.cfg.xml-->
            <!-- properties -->
            <property name="connection.username">PaintTracker</property>
            <property name="connection.url">jdbc:mysql://</property>
            <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
            <property name="connection.password">PaintTracker</property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="show_sql">true</property>
            <mapping resource="com/PaintTracker/struts/form/AddCustomerForm.hbm.xml"/>
    <!--AddCustomerForm.hbm.xml -->
         <class name="com.PaintTracker.struts.form.AddCustomerForm" table="customer">
              <id name="customerID" column="CustomerID" type="java.lang.Long" unsaved-value="0">
                   <generator class="identity"/>
              <property name="firstName" column="FirstName" type="java.lang.String"/>
              <property name="lastName" column="LastName" type="java.lang.String"/>
              <property name="streetAddress" column="StreetAddress" type="java.lang.String"/>
              <property name="middleInitial" column="MiddleInitial" type="java.lang.String"/>
              <property name="city" column="City" type="java.lang.String"/>
              <property name="state" column="State" type="java.lang.String"/>
              <property name="zipCode" column="ZipCode" type="java.lang.String"/>
              <property name="phoneNumber" column="PhoneNumber" type="java.lang.Long"/>
              <property name="emailAddressLeft" column="EmailAddressLeft" type="java.lang.String"/>
              <property name="emailAddressRight" column="EmailAddressRight" type="java.lang.String"/>
              <property name="company" column="Company" type="java.lang.String"/>          

    ok finally gotten back to this and rewrote a bunch of the code. I'm getting almost the same error, but not quite.
    I'm still getting org.hibernate.MappingException: Error reading resource: but it is pointing to the first mapping resource located inside the hibernate.cfg.xml.. so I know it is finding and making it inside the hibernate.cfg.xml.
    this is the code that the exception occurs in.
    the actual line is the configuration.configure(); in the else statement.
    public HibernateUtil(URL url2) {
              Configuration configuration = new Configuration();
              log.info("configuration_static is null");
              log.debug("configuring configuration_static from " + url2);
              try {
                   if (url2 != null)
                   this.sessionFactory = configuration.buildSessionFactory();
                   log.info("Configuration complete");
              } catch (HibernateException e) {
                   configuration = null;
                   log.info("Configuration failed.  Setting config to null!");
         }The resource I am trying to read is located correctly (eclipse lets you navigate to and choose the xml file to use.. it then builds the hibernate.cfg.xml file for you.)
    here is a copy of the resource that is giving me a problem... whichever resource I have listed first is the one the exception is thrown for... so I'm hoping I just have something mixed up in the way I'm writing my xml files.
    <hibernate-mapping package="com.WorkoutTracker.db.model">
         <class name="com.WorkoutTracker.db.model.User" table="user">
              <id name="userID" column="userId" type="java.lang.Long" unsaved-value="0">
                   <generator class="increment"/>
              <property name="userFName" column="userFName" type="java.lang.String"/>
              <property name="userLName" column="userLName" type="java.lang.String"/>

  • Hibernate mapping not working

    I have worked with Hibernate only once or twice before and never had the chance to go any deeper in it. But based on a working sample I have built this mapping for a new project of mine but unable I am to make it work. I'd be delighted to have point outs to what is leading to the exceptions on this... here are my codes:
    package br.com.realstatemanagement.entities;
    import java.util.Date; import java.util.Set; public class Customer { private int customerID; private String firstName; private String lastName; private Date birthDate; private String address; private String neighborhood; private String city; private String state; private String zipCode; private String country="BRASIL"; private String socSecNo; private String identity; private CustomerContacts[] contact; public CustomerContacts[] getContact() { return contact; } public void setContact(CustomerContacts[] contact) { this.contact = contact; } public void setCountry(String country) { this.country = country; } public int getCustomerID() { return customerID; } public void setCustomerID(int customerID) { this.customerID = customerID; } public String getZipCode() { return zipCode; } public void setZipCode(String zipCode) { this.zipCode = zipCode; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Date getBirthDate() { return birthDate; } public void setBirthDate(Date birthDate) { this.birthDate = birthDate; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getNeighborhood() { return neighborhood; } public void setNeighborhood(String neighborhood) { this.neighborhood = neighborhood; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getSocSecNo() { return socSecNo; } public void setSocSecNo(String socSecNo) { this.socSecNo = socSecNo; } public String getIdentity() { return identity; } public void setIdentity(String identity) { this.identity = identity; } public String getCountry() { return country; } }
    package br.com.realstatemanagement.entities; public class CustomerContacts { private int contactId; private String type; private String contact; public int getContactId() { return contactId; } public void setContactId(int contactId) { this.contactId = contactId; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getContact() { return contact; } public void setContact(String contact) { this.contact = contact; } }
    Follows the mappings....
    <?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>   <class name="br.com.realstatemanagement.entities.CustomerContacts" table="CustomerContacts">   <id name="contactId" type="int" column="contact_id" >   <generator class="increment"/>   </id>   <property name="type" type="string">     <column name="type" />   </property>   <property name="contact" type="string">     <column name="contact"/>   </property> </class> </hibernate-mapping>
    <?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>   <class name="br.com.realstatemanagement.entities.Customer" table="Customer">   <id name="customerID" type="int" column="customer_id" >   <generator class="increment"/>   </id>   <property name="firstName">     <column name="first_name" />   </property>   <property name="lastName">     <column name="last_name"/>   </property>   <property name="birthDate">     <column name="birthDate"/>   </property>   <property name="address">   <column name="address" />   </property>   <property name="neighborhood">   <column name="neighborhood" />   </property>   <property name="city">   <column name="city" />   </property>   <property name="state">   <column name="state" />   </property>   <property name="zipCode">   <column name="zipCode" />   </property>   <property name="country">   <column name="country" />   </property>   <property name="socSecNo">   <column name="socSecNo" />   </property>   <property name="identity">   <column name="identity" />   </property>   <many-to-one name="contact" column="contact_id" class="br.com.realstatemanagement.entities.CustomerContacts" insert="false" update="false"/> </class> </hibernate-mapping>
    Kindly help me out on this...
    Thanks very much

    Apologies... it is not that I did not want to put the exception details nor did I not intended to, I simply forgot... Here it is, am once again I am sorry for forgetting about it:
    description The server encountered an internal error () that prevented it from fulfilling this request.
    org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: Property 'CustomerContacts' not found on type br.com.realstatemanagement.entities.Customer
    root cause
    javax.el.PropertyNotFoundException: Property 'CustomerContacts' not found on type br.com.realstatemanagement.entities.Customer

  • Hibernate mapping editor not working fully

    My hibernate mapping editor is not working fully. I can manually enter a new property into the xml and the design pane will update but if I try to add a new property in the design pane it only adds "<property/>" without the attributes specified.
    I looked at my workshop log and I did find the following exception:
    !ENTRY org.eclipse.ui 4 0 2007-03-13 09:08:37.939
    !MESSAGE Failed to execute runnable (java.lang.NullPointerException)
    !STACK 0
    org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
         at org.eclipse.swt.SWT.error(SWT.java:3374)
         at org.eclipse.swt.SWT.error(SWT.java:3297)
         at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
         at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
         at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
         at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
         at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
         at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
         at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
         at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
         at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
         at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
         at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
         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.core.launcher.Main.invokeFramework(Main.java:336)
         at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
         at org.eclipse.core.launcher.Main.run(Main.java:977)
         at org.eclipse.core.launcher.Main.eclipse_main(Main.java:952)
         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 com.m7.installer.util.NitroxMain$1.run(NitroxMain.java:36)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
         at com.m7.wide.doceditor.XmlTagCommander$_A.actionPerformed(Unknown Source)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.AbstractButton.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at com.m7.wide.eclipse.jstudio.Plugin$_A.A(Unknown Source)
         at com.m7.wide.eclipse.jstudio.Plugin$4.run(Unknown Source)
         at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
         at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
         ... 32 more
    Any ideas on how to fix this?

    Yes, there is a known issue using the latest update of 1.4.2 or 1.5.0 vm.
    Generally, Workshop should work fine with 1.4.2 or 1.5.0 series. You can find the supported platform info at

  • Hibernate mapping

    I get an error when i do -> new Configuration().configure();  The error is "Could not parse mapping document from resource Client.hbm.xml"
    Glassfish gives the messages:
    configuring from resource: /hibernate.cfg.xml
    Configuration resource: /hibernate.cfg.xml
    Reading mappings from resource : Client.hbm.xml
    Error parsing XML: XML InputStream(1) Document is invalid: no grammar found.
    Error parsing XML: XML InputStream(1) Document root element "hibernate-mapping", must match DOCTYPE root "null".
    Here is my simple Client.hbm.xml mapping file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <class dynamic-insert="false" dynamic-update="false" mutable="true"
    select-before-update="false" table="Clients">
    <id column="cId" name="cid">
    <generator class="identity"/>
    <property column="cName" name="cName"/>
    <property column="cAddress" name="cAddress"/>
    "Please help!!"Edited by: dof on Jun 4, 2008 6:38 PM

    Might be because it's not finding the file? Should i understand from the error that it's finding the file but there is something else.
    Here is my hibernate.cfg.xml, maybe the problem is here
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
        <session-factory name="session1">
            <property name="hibernate.dialect">
            <property name="hibernate.connection.driver_class">
            <property name="hibernate.connection.url">
            <property name="hibernate.connection.username">
            <property name="hibernate.connection.password">
            <property name="hibernate.show_sql">
            <property name="hibernate.current_session_context_class">
            <mapping resource="Client.hbm.xml"/>

  • Repeated column in mapping error - Hibernate mapping

    Hi, I am relatively new to using Hibernate. I have two tables which I have tried to map unsuccesfully.
    Table 1:
    Primary Key(Instrument) -> Generated using function.
    Table 2:
    Primary Key(Instrument) -> Referenced from primary key of table 1
    Table 3:
    Primary Key(Instrument) -> Referenced from primary key of table 2
    Additional Column(Parent_Instrument) -> Referenced from the primary key of table 2
    So, two columns in Table 3 have to be mapped to the primary key of table 2.
    I have tried mapping them but am getting the following error:
    Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.db.csb.model.securitycreation.entities.tradegate.WiBonds column: INSTRUMENT (should be mapped with insert="false" update="false")
         at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:652)
         at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:674)
         at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:696)
         at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:450)
         at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
         at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
         at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
         at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)
         at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)
         at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
         ... 32 moreThe following is my code:
    TABLE 2
         @Column(name="INSTRUMENT", nullable=false,insertable=false,updatable=false)
         public long getInstrument() {
              return instrument;
         public void setInstrument(long instrument) {
              this.instrument = instrument;
         @JoinColumn(name = "INSTRUMENT", nullable=false, insertable=false)
         public Set<WiBonds> getWiBonds(){
              return Wi_Bonds;
         public void setWiBonds(Set<WiBonds> Wi_Bonds){
              this.Wi_Bonds = Wi_Bonds;
    TABLE 3
         @GenericGenerator(name = "fk_bondspec", strategy = "foreign", parameters = { @Parameter(name = "property", value = "BondSpec") })
         @GeneratedValue(generator = "fk_bondspec")
         @Column(name="INSTRUMENT", nullable=false,insertable=false,updatable=false)     
         public long getInstrument() {
              return instrument;
         public void setInstrument(long instrument) {
              this.instrument = instrument;
         @ManyToOne(targetEntity = BondSpec.class)
         @JoinColumn(name = "INSTRUMENT", nullable = false, insertable=false, updatable=false)
         public BondSpec getBondSpec() {
         public void setbondSpec(BondSpec bondspec) {
         @OneToOne(targetEntity = BondSpec.class)
         @JoinColumn(name = "PARENT_INSTRUMENT", nullable = false, insertable = false, updatable = false, unique=true)
         public long getParent_instrument() {
         public void setParent_instrument(long parent_instrument) {
         }What am I doing wrong?

    theraptor wrote:
    I probably didn't explain it correctly. I am trying to populate these tables with data about financial instruments.
    Table 2 and 3 share a primary key (INSTRUMENT). The primary key is generated in table 2, and the same value has to be later inserted into table 3. Sorry, I'm not following this at all. I don't think two tables should "share" a primary key. Both should have their own. Perhaps Table 3 would have a foreign key relationship with Table 2. OR the two tables should be one. But this notion of sharing doesn't sound right to me, and apparently Hibernate agrees. I think you have a bad design.
    Table 2 has a one to many relation with table 3. Then they can't share a primary key. It's 1:m, which you can easily model with Hibernate.
    (By many I mean it could be 0 as well, since hibernate does not provide a (one to 'maybe' one 'maybe zero) relation.Fine. Then it's a 1:m relationship. You've been thinking about it incorrect.
    Table 3 has an additional column PARENT_INSTRUMENT which is a foreign key to the the primary key of table 2.No. Wrong.
    Yes Instrument is financial in nature. However, I am not trying to model what you have spoken about above.Yes, I get it. Listen to Hibernate - your original idea is quite incorrect. Table 2 is 1:m with Table 3. Model it that way, and forget about this incorrect notion of "sharing a primary key". Give Table 3 its own auto generated key.

  • Hibernate mapping between JGeometry & SDO_Geometry

    Has anyone figured out how to create a hibernate mapping file for mapping between oracle.spatial.geometry.JGeometry and SDO_Geometry type? Haven't been able to figure out how to do it with UserTypes
    for instance I'd like to create a simple class like the following:
    import oracle.spatial.geometry.JGeometry;
    public class Building {
    private Long id;
    private String label;
    private JGeometry shape;
    public Building() {}
    with a corresponding hibernate mapping file that would contain something like:
    <class name="Building" table="BUILDING">
    <id name="id" column="ID" type="long">
    <generator class="native"/>
         <property name="label" type="string" length="100"/>
         <property name="shape" type="JGeometry"/>
    that would create a create SQL like:
    CREATE TABLE Buildings (
         id NUMBER PRIMARY Key,
         label VARCHAR(100),
         shape SDO_GEOMETRY)
         storage (initial 1m);

    We're specifying the custom type mapping using the OracleCustomTypeMappingAttribute and not in any configuration.
    The problem is occurring only on our test server and it has worked fine in the past.
    Strangely, our application works fine for a few hours and then the problem starts to occur.
    Once it happens, the problem stays until we re-start the web site or IIS.
    It's since we've done a completely fresh install of Oracle and .NET on the server so it's something to do with that I suspect.
    I can't seem to find any differences between the test server and our development machines however.
    I've tried to enable tracing but the trace file grew to over 1.5 gig within 30 mins so it would be impossible to let it run for hours.
    Even if we did have enough space, the file would be too big to analyse using any tools I know of.
    Any other suggestions would be welcomed.

  • How to do hibernate mapping for table or view without a primary key

    Anyone knows how to do hibernate mapping for table or view without a primary key?

    or you can make all column primary key .Anybody seriously considering that as a good idea should understand the implications:
    1. this requires that each row be unique - that's a minor issue normally, but can be a significant problem in some cases
    2. in practically all databases, a primary key constraint creates a unique index - this has many implications:
    a) in most databases, the index stores a copy of the column data that is indexed - this suggestion therefore more than doubles the data storage required for the data
    b) whenever an indexed column is changed, the index has to be maintained - this suggestion then more than doubles the work that each UPDATE statement has to do, since both the table and the index have to be maintained for any UPDATE at all
    This might work OK for toy projects, but it doesn't scale well at all...

  • Hibernate mapping XML files for the two SQL Server tables below.

    Hello all..,
    Question 1:
    I am working on a project that needs to support a database with an inherited legacy schema that you cannot change. The schema is provided below.Hibernate mapping XML files for the two SQL Server tables below. Please provide those two XML files. Assume some hypothetical package and class names. Assume that no "fancy" stuff such as lazy initialization, optimistic locking etc is needed at this time.
    [ANSWER_ID] [int] IDENTITY (1,1) NOT NULL,
    [POSITION] [int] NULL,
    [TEXT] [varchar](350) NULL
          [QUESTION_ID] [int] IDENTITY (1, 1) NOT NULL ,
          [TEXT] [varchar] (350) NULL
           FOREIGN KEY
          )Question 2:
    Assume that you are working on a project developing, say, a banking application. You are the Architect and thinking that Hibernate ORM should be used for the entire access to the relational database. As usual, you have created (or auto-generated) a set of HBM XML files as well as POJOs for which you define the mappings. Assume now that a new requirement has just popped up. The system needs to be able to import new bank accounts and user information in bulk from a very large XML file at once and store it in the database. Assume the XML file contains all necessary information to populate fields in database tables. As performance is very important for this operation. Given this description, how would you approach the problem?
    Please describe briefly.
    -Thanks and regards
    Praveen Soni

    You're not fooling anyone Dennis_Mox. But nice try.Jeez, man. Mail me at denismox[at]yandex.ru, I will show you that exact test, dammit.

  • Hibernate Mapping over 3 tables

    I have three tables (products, files_to_products, files), which relate to each other as follows:
    products <- files_to_products <- files
    |;id|;name|; |;product_id|;file_id|; |;id|;name|;data|;
    every product can have many or no files associtated to it.
    In the java bean, i have a
    Map<String filename, byte[] data>
    representing the file.
    How would the hibernate mapping look like for this? I somehow cant figure out how to map this table structure to something like
        <map name="files" order-by="size asc" table="FILES">       <key column="filename"/>       <element column="FILEDATA" type="binary"/>     </map>
    is this possible?

    It works only, if all datamanipulations are in the Source-DC. In other case, this DC don't have any data.

  • Hibernate: Mapping a 1:1 relation to a single class

    got the following situation:
    Two Database-Tables:
    1. loc_entry_history:
    - "ehid": primary key, auto_increment, unique
    - "time": Timestamp
    - "views": int
    2. loc_entry_history_info:
    - "ehid": foreign key on "loc_entry_history.ehid", primary key, unique
    - "title": String
    - "plz": String
    As you can see, this results in a 1:1 mapping between loc_entry_history and loc_entry_history_info. I now want to map these Data into ONE single class using Hibernate. I used the following Config:
    <class name="de.dbruhn.framework.test.beans.History" table="loc_entry_history">
          <id name="id" column="ehid">
             <generator class="native" />
          <property name="time" column="ehtime" type="timestamp" />
          <property name="ip" column="ehip" />
          <property name="views" column="ehviews" />
       <class name="de.dbruhn.framework.test.beans.Info" table="loc_entry_info">
          <id name="id" column="ehid">
               <generator class="foreign">
                   <param name="property">history</param>
           <one-to-one name="history" constrained="true"/>
          <property name="title" column="eititle" />
          <property name="plz" column="eiplz" />
       </class> but this is not what I want:
    I want the Data to be stored in a single Class, so one Class with the Name "history" where also the "title" and "plz" are stored.
    How can I do this? I tried changing the "class name="[...].Info" into "class name="[...].History" but then the property "history" is missing. But I cant add the property history to the class, it would be a self-reference.
    Thanks for any help

    Thanks for your reply.
    Because the data in loc_entry_info isn't always needed, so I put it into a second table to safe the table space!

  • Automatically create hibernate mapping

    I know there is a way to create a hibernate .hbm.xml file and the corresponding .java class automatically from a previously created DB table. Do you know how? Any Eclipse plug-in?

    The Eclipse stuff's easiest to use, but the Ant stuff allows for better build-automation.
    Personally I prefer to use annotations and retrofit to the existing schema where that's an option - but the generate-from-schema stuff can be useful as a first pass to save typing!
    Edit: Note, this is because the generated classes can sometimes be nasty to work with. You may want to simplify some of the relationships (e.g. converting join tables from entities in their own right into associations), which is stuff the tool can't always deduce for you.

  • Composite Key in Toplink Mapping File - equivalent to Hibernate?

    I have a POJO TestEntity which refers to primary key TestEntityKey. In Hibernate mapping hbm file, we define the entry as:
              <composite-id name="id" class="TestEntityKey">
                   <key-property name ="testEntityCode" column = "TEST_ENT_CODE" type = "string" />
    Please confirm how to create the composite id in Toplink means kindly help that how to map my id to key:
    <opm:field table="TEST_ENTITY_B" name="TEST_ENT_CODE" xsi:type="opm:column"/>

    Hey.. Thanks!
    I am clear about the concept about defining annotation based composite key. Also, I read in the documentation that I'll be needing to define as direct, aggregate or one-to-one. But, I am not able to define and run the same in the project mapping xml of toplink.
    It would be great if you can share some sample code for defining the same. For e.g. in my mentioned example, there is TestEntity POJO having 'id' as the attribute which gets populated with the testEntityCode of the TestEntityKey POJO. Please suggest the same for the same:
    <opm:field table="TEST_ENTITY_B" name="TEST_ENT_CODE" xsi:type="opm:column"/>

  • Composite-id + hibernate

    hello frnd,
    i give more about my prblm....
    this is code that i fetch record...(main)
    xml_config xConfig = new xml_config();
    Criteria cri = session.createCriteria(xml_config.class);
    String s="CA";
    //Query q = session.createQuery("from xml_config config where config.country_cd='CA'");
    cri.add(Restrictions.like("country_cd", s));
    cri.add(Restrictions.like("Dtd_version", "1.0"));
    List q = cri.list();//error line by eclipse ide
    Iterator itr = q.iterator();
    ArrayList<String> v = new ArrayList<String>();
    xConfig = (zespl_xml_config)itr.next();
    System.out.println("ICH FLAG "+xConfig.getICHFlag());
    System.out.println("Dtd file Name "+xConfig.getDtd_FileName());
    and this my mapping file
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    <class name="HibernateUtil.zespl_xml_config" table="zespl_gifnoc_lmx">
    <key-property name="country_cd" column="dc_yrtnuoc"/>
    <key-property name="Dtd_type" column="epyt_dtd"/>
    <key-property name="Dtd_version" column="noisrev_dtd"/>
    <key-property name="Dtd_FileName" column="eman_elif_dtd"/>
    <property name="ICHFlag" column="galf_hci"/>
    <property name="xls_FileName" column="eman_elif_lsx"/>
    and the output errror is ......
    Hibernate: select this_.dc_yrtnuoc as dc1_0_, this_.epyt_dtd as epyt2_0_, this_.noisrev_dtd as noisrev3_0_, this_.eman_elif_dtd as eman4_0_, this_.dc_yrtnuoc as dc1_1_0_, this_.epyt_dtd as epyt2_1_0_, this_.noisrev_dtd as noisrev3_1_0_, this_.eman_elif_dtd as eman4_1_0_, this_.galf_hci as galf5_1_0_, this_.eman_elif_lsx as eman6_1_0_ from zespl_gifnoc_lmx this_ where this_.dc_yrtnuoc like ? and this_.noisrev_dtd like ?
    java.lang.ClassCastException: HibernateUtil.xml_config
    at org.hibernate.loader.Loader.getKeyFromResultSet(Lo ader.java:650)
    at org.hibernate.loader.Loader.getRowFromResultSet(Lo ader.java:277)
    at org.hibernate.loader.Loader.doQuery(Loader.java:38 4)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:203)
    at org.hibernate.loader.Loader.doList(Loader.java:149 9)
    at org.hibernate.loader.Loader.list(Loader.java:1482)
    at org.hibernate.loader.criteria.CriteriaLoader.list( CriteriaLoader.java:111)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1246)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl. java:299)
    at HibernateDemo.Main.main(Main.java:87)
    and my java bean is...
    public class xml_config
    String country_cd;
    String ICHFlag;
    String Dtd_type;
    String Dtd_version;
    String Dtd_FileName;
    String xls_FileName;
    public String getCountry_cd() {
    return country_cd;
    public void setCountry_cd(String country_cd) {
    this.country_cd = country_cd;
    public String getDtd_FileName() {
    return Dtd_FileName;
    public String getDtd_type() {
    return Dtd_type;
    public String getDtd_version() {
    return Dtd_version;
    public String getICHFlag() {
    return ICHFlag;
    public String getXls_fileName() {
    return xls_FileName;
    public void setDtd_FileName(String dtd_FileName) {
    Dtd_FileName = dtd_FileName;
    public void setDtd_type(String dtd_type) {
    Dtd_type = dtd_type;
    public void setDtd_version(String dtd_version) {
    Dtd_version = dtd_version;
    public void setICHFlag(String flag) {
    ICHFlag = flag;
    public String getXls_FileName() {
    return xls_FileName;
    public void setXls_FileName(String xls_FileName) {
    this.xls_FileName = xls_FileName;
    if any one have solution then please help me...
    thanx and regards,
    Message was edited by:

    thanx forIf you can't be bothered to spell out words like "thanks" and "please" I don't see why I should spell out answers for you.
    but after changing code To what? I AM NOT PSYCHIC.
    problem remains same...If you have the same problem, you have the same bug. Your code is wrong in the same way. Perhaps you didn't compile the new code? I don't know.
    If you have a different problem, you have a different bug. I haven't seen your code, and you haven't described the problem or pasted the error messages. I have no idea what the problem is.
    please tell what r conditions to use <composite-id>The fields have to collectively form a primary key. That's the only condition.
    i have only one table with four primary keys noFour primary key fields. It's impossible to have multiple primary keys in a table.
    pls help me and give proper solution to solve my
    problem."That didn't work, I did something, fix it?" I'm becoming disinclined to help someone who's being quite this unhelpful.
    And what is with the naming convention? What on earth posessed you to do that?
    D. (quite cranky today).

Maybe you are looking for

  • Xerces cannot find symbol problem

    In my program I get an Xml from an exist database and want to place it in the hard drive. I have made the xerces imports I need: import org.apache.xerces.domx.XGrammarWriter.OutputFormat; import org.apache.xml.serialize.XMLSerializer;I have the jar o

  • "Error Details" is empty...

    When ever I've got an error in the ESB Control instances, and tryr to open the the error tab page - the dialog is completely empty? Is this a bug or? Regards, Henrik

  • Invalid Product Key

    I bought CS6 last month and i've been trying to download the full version for a month now. When I go to the website to enter my product key it says it's invalid?!

  • Keyboard inaccurate after a sentance or two

    I have had a problem with my keyboard since 2 updates ago. Any typing app after 1-2 sentences the typing doesn't register. It will register a letter 2 spaces to the left. I am unable to type P, L, or M as they are on the right side of the keyboard. I

  • SCCM Client entry in SCCM console for new VM with same hostname

    HI, I have Hyper V server with several VM's running with server OS. Recently I have stopped 2 VM's with OS windows server 2008 & 2012 & recreated new VM's with same hostnames & IP addresses. Problem is I am unable to install SCCM client on New VM as