Regarding Hibernate Criteria

Can we select few columns through criteria query?
If yes plz give me an example how to do it.

shakti wrote:
can u give me a small exampleWell, here's someone doing essentially what you want: http://stackoverflow.com/questions/1618394/use-fewer-columns-on-sql-query-through-hibernate-projections-on-entity-with-many
Note how he's also being told that using the criteria API for this is stupid.

Similar Messages

  • Weblogic 10.3.5.0 problem with hibernate criteria

    Hi,
    I have problim with using Hibernate Criteria on Weblogic server. Everithing works fine on Tomcat.
    On weblogic I can execute this on Weblogic :
    Query query = sessionFactory.getCurrentSession().createSQLQuery("select sysdate from dual");//To get string date
    String result = query.uniqueResult().toString();
    ,but I have problem with executing criteria which work on tomcat:
         Criteria crit=sessionFactory.getCurrentSession().createCriteria(MyclassWithHibernate.class);
         crit.setFirstResult(0);
         crit.setMaxResults(1);
         return (MyclassWithHibernate) crit.uniqueResult();
    On weblogic, same criteria return me null and I get this exception:
    java.lang.NullPointerException
         at test.Rasa.getValueTest(Rasa.java:68)
         at test.Rasa$$FastClassByCGLIB$$b6e6c0b9.invoke(<generated>)
         at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
         at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
         at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
         at test.Rasa$$EnhancerByCGLIB$$e20363db.getValueTest(<generated>)
         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:597)
         at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:418)
         at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
         at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1400)
         at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005)
         at flex.messaging.endpoints.AbstractEndpoint$$FastClassByCGLIB$$1a3ef066.invoke(<generated>)
         at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
         at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
         at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:576)
         at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$64941f01.serviceMessage(<generated>)
         at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103)
         at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
         at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
         at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
         at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166)
         at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
         at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$64941f01.service(<generated>)
         at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:101)
         at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
         at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
         at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
         at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Enwironment is :
    WebLogic Server 10.3.5.0
    Hibernate 3.x
    Spring 3.x
    I am using this configuration i application context:
    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
    <property name="connectionCachingEnabled" value="true" />
    <property name="URL" value="jdbc:oracle:thin:@address:port:db" />
         <property name="user" value="myuser"></property>
         <property name="password" value="mypass"></property>
    <property name="connectionCacheProperties">
    <props merge="default">
    <prop key="MinLimit">3</prop>
    <prop key="MaxLimit">20</prop>
    </props>
    </property>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref ="dataSource"/>
              <property name="packagesToScan" value="test*" />
    <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
              <property name="hibernateProperties">
                        <props>
                        <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
                        <prop key="hibernate.format_sql">true</prop>
                        <prop key="hibernate.use_sql_comments">true</prop>
                        <prop key="hibernate.generate_statistics">true</prop>
    </props>
              </property>
    </bean>
    Thanks for any help.

    Which code snippet is throwing the nullpointerexception?
    Does Spring create the SessionFactory?
    Maybe it is related but when running Hibernate on WebLogic you have to take care of a classloading issue with the antlr libary,
    more information can be found here: http://middlewaremagic.com/weblogic/?p=5861

  • How to Eliminate Duplicates in Hibernate Criteria Query

    Hi all,
    Anyone who know how to eliminate duplicates in Hibernate Criteria Query ?
    Thanks,
    Lanz

    You should try asking this in a hibernate forum

  • Hibernate Criteria

    Hello every one, can someone could help me?
    i have a problem while doing a sub query: here is the script :
    DetachedCriteria subInfo = DetachedCriteria.forClass(ActReg.class)
    .createAlias("ActType", "t")
    .createAlias("Incident", "i")
    .add(Restrictions.eq("t.Id", 158))
    .setProjection(Projections.property("i.Id"));
    Criteria critInfo = session.createCriteria(IncData.class)
    .add(Restrictions.between("DateLogged",st_date,end _date))
    .add(Subqueries.in("Id",subInfo));
    the output is : java.lang.String cannot be cast to java.lang.Integer
    Thank you for any help

    yes in fact, i get this error on this line :
    Iterator iter = (IncData) critInfo.list().iterator();but i dont undestand why should i get a List<Integer> or List<String>
    I must or i want to get a List<IncData> (from the session.createCriteria(IncData.class)The error may come because i want to do a subquery, if i remove the .add(Subqueries.in("Id",subInfo)); , then it will return without a problem a List<IncData>. but its not the query that i want. I am new in Hibernate Criteria.
    In sql, the query may look like : select incdata.* from incdata where incdata.id in (select actreg.incident_id from actreg)thans for answer and for your help.
    Edited by: stunaz on Dec 2, 2008 10:45 PM

  • Regarding Selection Criteria

    Hi All,
    Is it mandatory to have a info object in a cube which is used in selection criteria,
    which appears in Data selection tab of info package maintenance.
    Plz let me know ASAP.
    Thanks&Regards
    Message was edited by:
            sarau

    Hi
    in the infopack u get those in the selection tab which u check mark in the Datasource as a selection tab. now if they are presnt in the IP as selection then loading data will be helpful but if u dont add them in the cube how will be able to make them available in the selection scrreen of the query coz u need to make a varialble on them and untill and unless these are not present in cube u wont be able to make a varialble and hence wont be able to make them appear in the selection screen of the query
    hope this is helpful assign points if applicable
    thanks
    puneet

  • Regarding Hibernate

    Hi,
    I am studing hibernate .so that waht r the jar files i need and where i have to download ?
    Because it throw error for import package when i compile the java source?
    (or.hibernate cannot be resloved)
    Regards,
    John
    Mobile: +919865315105

    http://www.laliluna.de/first-hibernate-example-tutorial.html
    checkout the example given there...
    it gives you list of basic libraries which you need if are thinking to download all of them not to worry please download hibernate core library from the below link you'd be getting hibernate3.jar along with all the dependecies in there.
    http://sourceforge.net/project/downloading.php?group_id=40712&use_mirror=superb-east&filename=hibernate-3.2.5.ga.zip&70356791
    Hope that might help :)
    REGARDS,
    RaHuL

  • Doubt regarding multiple criteria in order by clause

    Hi, I don't understand the effect of multiple elements inside the order by clause. I have the following example table:
    factor_x | factor_y | price
    =====================
    1 | 5 | 1000
    2 | 4 | 6970
    3 | 3 | 3688
    4 | 2 | 9087
    5 | 1 | 10000
    =====================
    So I tried: select price from pricetable order by factor_x; results as follows:
    1000
    6970
    3688
    9087
    10000
    Then: select price from pricetable order by factor_y; results as follows:
    10000
    9087
    3688
    6970
    1000
    Then: select price from pricetable order by factor_x, factor_y; results as follows:
    1000
    6970
    3688
    9087
    10000
    which is same as using order by factor_x. Can anyone tells me what is the effect of adding a 2nd, 3rd..... criterion in the order by clause? Because in this example I cannot see the difference. Many thanks.

    Hi,
    I did a little change in your data. Hope it will help you to understand.
    SQL> WITH T AS (SELECT 1 X , 1 Y , 1000 PRICE FROM DUAL UNION A
      2  SELECT 2 , 4 , 6970 FROM DUAL UNION ALL
      3  SELECT 4 , 3 , 3688 FROM DUAL UNION ALL
      4  SELECT 4 , 2 , 9087 FROM DUAL UNION ALL
      5  SELECT 4 , 5 , 10000 FROM DUAL)
      6  SELECT PRICE,X,Y FROM T ORDER BY X;
         PRICE          X          Y
          1000          1          1
          6970          2          4
          9087          4          2
         10000          4          5
          3688          4          3
    SQL> WITH T AS (SELECT 1 X , 1 Y , 1000 PRICE FROM DUAL UNION A
      2  SELECT 2 , 4 , 6970 FROM DUAL UNION ALL
      3  SELECT 4 , 3 , 3688 FROM DUAL UNION ALL
      4  SELECT 4 , 2 , 9087 FROM DUAL UNION ALL
      5  SELECT 4 , 5 , 10000 FROM DUAL)
      6  SELECT PRICE,X,Y FROM T ORDER BY X,Y;
         PRICE          X          Y
          1000          1          1
          6970          2          4
    9087 4 2
    3688 4 3
    10000 4 5
    SQL>Regards
    Avinash

  • Regarding Selection Criteria features in BI7 Info package maintenance

    Hi,
    In BI7.0, I have to load data from the Business content ODS, 0FIGL_O02 to Customized ODS by restricting the data as per the document types.
    Do we have that feature in BI7, to restrict the data in info package maintenance's selection criteria.Please let me know, when we dont have that feature...where can i apply this restriction for loading one data target to another data target.
    Thanks,

    In BI 7.0 you will be using DTPs to load data from one DSO to the other.  There will be no Infopackages involved.
    You can filter based on Document types in two ways. 
    1.  Build the filter in the start routine of your transformation itself  to delete datapackage whenever document type is not equal to what you want.
    2.  DTPs have a filter button.  When you go in change mode you will be able to choose the infoobjects on which you want to filter.  You can enter the required Document types in the filter here.
    If helpful, assign points

  • Regarding a criteria.Please see my query

    In my table 'Posting' i have the columns
    id_trade_ref        type
    5V973781B           NEW
    5V973781B           SET
    5V973781B           REV
    Criteria:
    If the posting is booked having type SET and REV with identical 'id_trade_ref',
    then display only 'NEW'
    So I am using this in my where clause:
    SQL Query
    from posting p
    where p.id_ref_type = '5V973781B '
    and .type in ('NEW')
    Because I know there are MULTIPLE identical id_ref_type, I will display NEW.
    But suppose,there is only one record in the POSTING TABLE with type as REV.
    id_trade_ref        type
    5V973781B        REV
    As there is only one record,REV,this needs to be displayed too.
    How can I make this check in the where clause?
    ie,If identical id_trade_ref,then display 'NEW'
       If single,then display that one only
       Do I use the CASE Select?
    Can someone help?
    Has anyone understood my query?

    Well, you never give any hint about your business logic, so we can only provide low help.
    Anyway, the following query gives the required resuld on your data sample...
    TEST> CREATE TABLE monal
      2  (
      3  id_trade_ref     NUMBER,
      4  id_posting_ref   NUMBER,
      5  id_posting_type  CHAR(3 CHAR)
      6  );
    Table created.
    TEST> INSERT INTO monal VALUES (2231229, 11749444,'SET');
    1 row created.
    TEST> INSERT INTO monal VALUES (2231229, 11749446,'REV');
    1 row created.
    TEST> INSERT INTO monal VALUES (2231229, 11749448,'SET');
    1 row created.
    TEST> COMMIT;
    Commit complete.
    TEST> SELECT *
      2  FROM monal
      3  ORDER BY id_trade_ref, id_posting_ref;
    ID_TRADE_REF ID_POSTING_REF ID_
         2231229       11749444 SET
         2231229       11749446 REV
         2231229       11749448 SET
    TEST> SELECT *
      2  FROM monal up
      3  WHERE id_trade_ref IN (SELECT id_trade_ref
      4                     FROM monal
      5                     WHERE id_posting_type = 'SET'
      6                     GROUP BY id_trade_ref
      7                     HAVING COUNT(*) >1)
      8  AND id_posting_type = 'SET'
      9  AND id_posting_ref = (SELECT MAX(id_posting_ref)
    10                     FROM monal
    11                     WHERE id_trade_ref=up.id_trade_ref
    12                     AND id_posting_type='SET')
    13  ;
    ID_TRADE_REF ID_POSTING_REF ID_
         2231229       11749448 SETYoann.

  • Regarding Search Criteria

    Hi All we are using FAST ESP 5.3.1 version can some one let me know whether "/" character is allowed in the search criteria.

    Raghu,
    ESP does not  index punctuation characterssuch as  # % & ' + , - / ; < = > @ [ \ ] _ ` { | } ~ ( ) ^ $ ! “ :
    2. These characters # % & ' + , - / ; < = > @ [ \ ] _ ` { | } ~ are either stripped out or if they are joining two words (no white space) turn the words into a phrase.
    However , if you want to index "/", yo can modify the tokenization file(%FASTSEARCH%\etc\tokenizer\tokenization.xml)  to allow the character to be indexed.

  • Adobe AIR help; question regarding search criteria with multibyte characters

    Hi,
    I created Adobe AIR application with Robohelp 9 (using FM 10 files as source, and texts are written in Japanese and English),
    and happend to find that search function in AIR application doesn't catch keywords correctly.
    For example,
    1. If you type "文字" and "スタイル" with single byte space in search window, the result appears for both "文字" and "スタイル".
    2. If you type "文字" and "スタイル" with double byte space in search window, the result doesn't match for anything.
    3. If you type "文字スタイル" (in one word) in search window, the result doesn't match for anything.
    Same thing happens for the case "文字種" (literally, "文字"+"種", the meaning is almost the same).
    But, if you type search words which is all in Katakana, the result seems to be fine.
    Is there any limitation for multibyte characters support? Or, this behaviour is a feature??
    If so, how can make AIR application "hit" correct words?
    Thank you very much for your kind help in advance!

    On this one your best course of action is to contact Adobe Support. They will likely require your project and there is one thing I would suggest you do first. Create a new project with just a few topics to prove the problem exists there as well. If it does it will be a simpler upload and you will know the problem is repeatable.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Many-to-one relationship using annotations in hibernates...

    my pojo class is M_Product_Category
    package com.netree.model;
    import java.io.Serializable;
    import java.util.HashSet;
    import java.util.Set;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import javax.persistence.OneToMany;
    import javax.persistence.JoinColumn;
    @Entity
    @Table(name="m_product_category")
    public class M_Product_Category implements Serializable{
         @Id
         @Column(name="MPC_ID")
         @GeneratedValue
         private int mpc_Id;
         @Column(name="IsActive")
         private int isActive;
         @Column(name="Category_Name")
         private String category_Name;
         @Column(name="Category_Description")
         private String category_Description;
         @Column(name="Parent_MPC_ID")
         private int parent_MPC_ID;
         public M_Product_Category(){
         public M_Product_Category(int mpc_Id, int isActive, String category_Name,
                   String category_Description, int parent_MPC_ID) {
              super();
              this.mpc_Id = mpc_Id;
              this.isActive = isActive;
              this.category_Name = category_Name;
              this.category_Description = category_Description;
              this.parent_MPC_ID = parent_MPC_ID;
         public int getMpc_Id() {
              return mpc_Id;
         public void setMpc_Id(int mpc_Id) {
              this.mpc_Id = mpc_Id;
         public int getIsActive() {
              return isActive;
         public void setIsActive(int isActive) {
              this.isActive = isActive;
         public String getCategory_Name() {
              return category_Name;
         public void setCategory_Name(String category_Name) {
              this.category_Name = category_Name;
         public String getCategory_Description() {
              return category_Description;
         public void setCategory_Description(String category_Description) {
              this.category_Description = category_Description;
         @OneToMany(cascade=CascadeType.ALL)
         @JoinColumn(name="Parent_MPC_ID", referencedColumnName="MPC_ID")
         public int getParent_MPC_ID() {
              return parent_MPC_ID;
         public void setParent_MPC_ID(int parent_MPC_ID) {
              this.parent_MPC_ID = parent_MPC_ID;
    This is anothe pojo class i.e., ProductMaster:
    package com.netree.model;
    import java.io.Serializable;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.Table;
    @Entity
    @Table(name = "M_Product_Master")
    public class ProductMaster implements Serializable {
         @Id
         @GeneratedValue
         @Column(name = "MPM_ID")
         private int mpmID;
         @Column(name = "Product_Name")
         private String productName;
         @Column(name = "Product_Description")
         private String productDescription;
         @Column(name = "Standard_Cost")
         private String price;
         @Column(name = "Image_URL_Big")
         private String image;
         @Column(name = "MPC_ID")
         private int mpc_id;
         public int getMpc_id() {
              return mpc_id;
         public void setMpc_id(int mpc_id) {
              this.mpc_id = mpc_id;
         private M_Product_Category product_Category;
         @ManyToOne(cascade = CascadeType.ALL)
         @JoinColumn(name = "mpc_id", referencedColumnName = "MPC_ID")
         public M_Product_Category getProduct_Category() {
              return product_Category;
         public void setProduct_Category(M_Product_Category product_Category) {
              this.product_Category = product_Category;
         public int getMpmID() {
              return mpmID;
         public void setMpmID(int mpmID) {
              this.mpmID = mpmID;
         public String getProductName() {
              return productName;
         public void setProductName(String productName) {
              this.productName = productName;
         public String getProductDescription() {
              return productDescription;
         public void setProductDescription(String productDescription) {
              this.productDescription = productDescription;
         public String getPrice() {
              return price;
         public void setPrice(String price) {
              this.price = price;
         public String getImage() {
              return image;
         public void setImage(String image) {
              this.image = image;
    util class...
    package com.netree.Util;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.AnnotationConfiguration;
    public class HibernateUtil {
         public static SessionFactory getSessionFactory() {
              System.out.println("sessionFactory");
              AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration();
              System.out.println("annotationConfiguration");
              annotationConfiguration=annotationConfiguration.configure("com/netree/Cfg/Hibernate.cfg.xml");
              SessionFactory sessionFactory = annotationConfiguration.buildSessionFactory();
              return sessionFactory;
    package com.netree.DaoImpl;
    import java.util.Iterator;
    import java.util.List;
    import org.hibernate.Criteria;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.criterion.Restrictions;
    import com.netree.Util.HibernateUtil;
    import com.netree.model.ProductMaster;
    public class ProductMasterImpl {
    public static void main(String args[]) {
                             try{
                                  System.out.println("sessionFactory starts");
              SessionFactory sessionFactory=HibernateUtil.getSessionFactory();
              System.out.println("sessionFactory ends");
              Session session=sessionFactory.getCurrentSession();
                                  Transaction transaction=session.beginTransaction();
         Criteria ctr=session.createCriteria(ProductMaster.class).add(Restrictions.eq("mpc_id",new Integer(39)));
         List<ProductMaster> list=ctr.list();
                   @SuppressWarnings("rawtypes")
                                  Iterator iterator = list.iterator();
                   while (iterator.hasNext()) {
                        ProductMaster productMaster = (ProductMaster) iterator.next();
    System.out.println(productMaster.getMpmID());
    System.out.println(productMaster.getProductName());
    System.out.println(productMaster.getProductDescription());
    System.out.println(productMaster.getPrice());
    System.out.println(productMaster.getImage());
    System.out.println(productMaster.getProduct_Category().getMpc_Id());
    System.out.println(productMaster.getProduct_Category().getCategoryName());
    System.out.println(productMaster.getProduct_Category().getCategory_Description());
                   session.close();
         catch(Exception ex){
         System.out.println(ex.getMessage());
                        finally{
    Already i have two tables in database with the suitable records... I want to retrieve the data by using MPC_ID from both tables....
    when i run this program i am getting query but it is showing exception i.e....
    Hibernate: select this_.MPM_ID as MPM1_1_0_, this_.Image_URL_Big as Image2_1_0_, this_.MPC_ID as MPC3_1_0_, this_.Standard_Cost as Standard4_1_0_, this_.Product_Description as Product5_1_0_, this_.Product_Name as Product6_1_0_, this_.product_Category as product7_1_0_ from M_Product_Master this_ where this_.MPC_ID=?
    could not execute query
    could u pls help me in this regard.....

    in the cube do you have both of these values
    PT02 211886
    PT02 211887
    or its always either one of them. I dont think changing your cube design would prove any helpful in this scenario. I believe its more of a data issue than the design issue. You would need to change the way the data is entered into the cube with the different measurement assigned to the unit.
    on a second thought(I understand that you dont have a luxury to change the cube design),  when you say you can see diff measurement type assigned to one unit in the masterdata, you can make the unit attribute as a navigational attribute in both the IO and cube. And just map measurent type in the update rules and derive the units from the masterdata table in the report.... does it make sense?
    Message was edited by:
            voodi

  • Error While using date fields in HIbernate Criteraia

    I am trying a sample applciation using Hibernate with JPA. I am using annotations to map database table with Java class.I am using org.hibernate.Criteria to form where clause. My code looks as follows:
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("PERSISTANCE_UNIT");
    EntityManger em = emf.createEntityManager();
    Session session = em.getDelegate();
    Criteria criteria = session.createCriteria(MyDO.class)
    criteria.add(Restrictions.eq("myDO.date",myDO.getDate()));
    List list = criteria.list();
    I am searching the data base based on the date field (myDO is an instance of MyDO.class which contains the mapping to the data base table). While running the application first time after publishing to server, I am getting the following error. For subsequent running of the application I am not getting any error and the appliaction was running with actual results.
    JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: -181, SQLState: 22007
    JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions THE STRING REPRESENTATION OF A DATETIME VALUE IS NOT A VALID DATETIME VALUE
    org.hibernate.exception.DataException: could not execute query
         at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
         at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
         at org.hibernate.loader.Loader.doList(Loader.java:2223)
         at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
         at org.hibernate.loader.Loader.list(Loader.java:2099)
         at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
         at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
         at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
    Can anybody help in fixing the problem.
    Thanks in advance.

    Resolved the issue by setting System date where expected

  • Hibernate Issue

    Hi
    Yesterday i posted one query regarding hibernate.No one replied me with correct answer.So i am posting it again.i am using hibernate to populate data from database to my table control.The table columns contains textfields.i am using objectlistdataprovider to display the list of values from hibernate bean.My problem is i can update the values in the table displayed on UI(as it is a textfield).but i am not able to get the values from textfield inside table.i wan to know how can i get the values back from textfield inside a table control so tht i can update tht back to database using hibernate. i am not using spring here
    Thanks
    Shameer

    You should be able to get back the data from the text field. In hibernate, you get the List of data from the hibernate session. Using that List, you must be creating the ListDataProvider. But when the table is submited after the data is entered in the textfield only the ArrayListDataProvider is modified. You need to get the data from the List inside the data provider and comit it back using hibernate session. One of our ineterns was able to do this for her MS project.
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • Unable to read one-to-many relations using Hibernate

    Hi,
    I am trying with a very simple one-to-many relationship. When I am storing the objects, there are no problems. But when I am trying to read out the collection, it says invalid descriptor index. Please help.
    Regards,
    Hibernate version:
    hibernate-3.1rc2
    Mapping documents:
    <?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="Parent">
              <id name="id">
                   <generator class="identity"/>
              </id>
              <set name="children">
                   <key column="parent_id"/>
                   <one-to-many class="Child"/>
              </set>
         </class>
         <class name="Child">
              <id name="id">
                   <generator class="identity"/>
              </id>
              <property name="name"/>
         </class>
    </hibernate-mapping>
    Code between sessionFactory.openSession() and session.close():
    The Parent class:
    public class Parent
         private Long id ;     
         private Set children;
         Parent(){}
         public Long getId()
              return id;
         public void setId(Long id)
              this.id=id;
         public Set getChildren()
              return children;
         public void setChildren(Set children)
              this.children=children;
    The Child class:
    public class Child
         private Long id;
         private String name;
         Child(){}
         public Long getId()
              return id;
         private void setId(Long id)
              this.id=id;
         public String getName()
              return name;
         public void setName(String name)
              this.name=name;
    The Main class:
    public class PCManager
         public static void main(String[] args)
              PCManager mgr = new PCManager();
              List lt = null;
              if (args[0].equals("store"))
                   mgr.createAndStoreParent(new HashSet(3));
              else if (args[0].equals("list"))
                   mgr.listEvents();
              HibernateUtil.getSessionFactory().close();
         private void createAndStoreParent(HashSet s)
              HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
              Parent p1 = new Parent();
              int size = 3;
              for (int i=size; i>0; i--)
                   Child c = new Child();
                   c.setName("Child"+i);
                   s.add(c);
              p1.setChildren (s);
              Iterator elems = s.iterator();
              do {     
                   Child ch = (Child) elems.next();
                   HibernateUtil.getSessionFactory().getCurrentSession().save(ch);
              }while(elems.hasNext());
              HibernateUtil.getSessionFactory().getCurrentSession().save(p1);
              HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
         private void listEvents()
              HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
              Parent result = (Parent) HibernateUtil.getSessionFactory().getCurrentSession().load(Parent.class, new Long(1));
              System.out.println("Id is :"+ result.getId());
              Set children = result.getChildren();
              Iterator elems = children.iterator();
              do {     
                   Child ch = (Child) elems.next();
                   System.out.println("Child Name"+ ch.getName());
              }while(elems.hasNext());
              HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();          
    Full stack trace of any exception that occurs:
    When I run with "hbm2ddl.auto" property as validate and trying to list the contents, I get the following out put.
    C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc2\MyHibernate>ant run -Da
    ction=list
    Buildfile: build.xml
    clean:
    [delete] Deleting directory C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    [mkdir] Created dir: C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc
    2\MyHibernate\bin
    copy-resources:
    [copy] Copying 4 files to C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    compile:
    [javac] Compiling 5 source files to C:\Documents and Settings\mirza\Desktop\
    hibernate-3.1rc2\MyHibernate\bin
    run:
    [java] 09:09:23,433 INFO Environment:474 - Hibernate 3.1 rc2
    [java] 09:09:23,449 INFO Environment:489 - loaded properties from resource
    hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true, hibernate
    .cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.dial
    ect=org.hibernate.dialect.SQLServerDialect, hibernate.max_fetch_depth=1, hiberna
    te.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.
    substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.cac
    he.region_prefix=hibernate.test, hibernate.jdbc.batch_versioned_data=true, hiber
    nate.connection.pool_size=1}
    [java] 09:09:23,465 INFO Environment:519 - using java.io streams to persis
    t binary types
    [java] 09:09:23,465 INFO Environment:520 - using CGLIB reflection optimize
    r
    [java] 09:09:23,481 INFO Environment:550 - using JDK 1.4 java.sql.Timestam
    p handling
    [java] 09:09:23,559 INFO Configuration:1257 - configuring from resource: /
    hibernate.cfg.xml
    [java] 09:09:23,559 INFO Configuration:1234 - Configuration resource: /hib
    ernate.cfg.xml
    [java] 09:09:23,872 INFO Configuration:460 - Reading mappings from resourc
    e: PCMapping.hbm.xml
    [java] 09:09:24,013 INFO HbmBinder:266 - Mapping class: Parent -> Parent
    [java] 09:09:24,045 INFO HbmBinder:266 - Mapping class: Child -> Child
    [java] 09:09:24,045 INFO Configuration:1368 - Configured SessionFactory: n
    ull
    [java] 09:09:24,061 INFO Configuration:1014 - processing extends queue
    [java] 09:09:24,061 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:09:24,061 INFO HbmBinder:2233 - Mapping collection: Parent.child
    ren -> Child
    [java] 09:09:24,076 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:09:24,076 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:09:24,155 INFO DriverManagerConnectionProvider:41 - Using Hibern
    ate built-in connection pool (not for production use!)
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:42 - Hibernate co
    nnection pool size: 1
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:45 - autocommit m
    ode: false
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:80 - using driver
    : sun.jdbc.odbc.JdbcOdbcDriver at URL: jdbc:odbc:MySQL
    [java] 09:09:24,170 INFO DriverManagerConnectionProvider:86 - connection p
    roperties: {}
    [java] 09:09:24,264 INFO SettingsFactory:77 - RDBMS: Microsoft SQL Server,
    version: 08.00.0194
    [java] 09:09:24,264 INFO SettingsFactory:78 - JDBC driver: JDBC-ODBC Bridg
    e (SQLSRV32.DLL), version: 2.0001 (03.85.1117)
    [java] 09:09:24,296 INFO Dialect:100 - Using dialect: org.hibernate.dialec
    t.SQLServerDialect
    [java] 09:09:24,311 INFO TransactionFactoryFactory:31 - Using default tran
    saction strategy (direct JDBC transactions)
    [java] 09:09:24,327 INFO TransactionManagerLookupFactory:33 - No Transacti
    onManagerLookup configured (in JTA environment, use of read-write or transaction
    al second-level cache is not recommended)
    [java] 09:09:24,327 INFO SettingsFactory:125 - Automatic flush during befo
    reCompletion(): disabled
    [java] 09:09:24,327 INFO SettingsFactory:129 - Automatic session close at
    end of transaction: disabled
    [java] 09:09:24,343 INFO SettingsFactory:144 - Scrollable result sets: ena
    bled
    [java] 09:09:24,343 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): d
    isabled
    [java] 09:09:24,343 INFO SettingsFactory:160 - Connection release mode: au
    to
    [java] 09:09:24,358 INFO SettingsFactory:184 - Maximum outer join fetch de
    pth: 1
    [java] 09:09:24,358 INFO SettingsFactory:187 - Default batch fetch size: 1
    [java] 09:09:24,358 INFO SettingsFactory:191 - Generate SQL with comments:
    disabled
    [java] 09:09:24,358 INFO SettingsFactory:195 - Order SQL updates by primar
    y key: disabled
    [java] 09:09:24,358 INFO SettingsFactory:338 - Query translator: org.hiber
    nate.hql.ast.ASTQueryTranslatorFactory
    [java] 09:09:24,374 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTran
    slatorFactory
    [java] 09:09:24,374 INFO SettingsFactory:203 - Query language substitution
    s: {no='N', yes='Y'}
    [java] 09:09:24,374 INFO SettingsFactory:209 - Second-level cache: enabled
    [java] 09:09:24,374 INFO SettingsFactory:213 - Query cache: disabled
    [java] 09:09:24,374 INFO SettingsFactory:325 - Cache provider: org.hiberna
    te.cache.HashtableCacheProvider
    [java] 09:09:24,374 INFO SettingsFactory:228 - Optimize cache for minimal
    puts: disabled
    [java] 09:09:24,374 INFO SettingsFactory:233 - Cache region prefix: hibern
    ate.test
    [java] 09:09:24,405 INFO SettingsFactory:237 - Structured second-level cac
    he entries: disabled
    [java] 09:09:24,437 INFO SettingsFactory:257 - Echoing all SQL to stdout
    [java] 09:09:24,452 INFO SettingsFactory:264 - Statistics: disabled
    [java] 09:09:24,452 INFO SettingsFactory:268 - Deleted entity synthetic id
    entifier rollback: disabled
    [java] 09:09:24,452 INFO SettingsFactory:283 - Default entity-mode: POJO
    [java] 09:09:24,593 INFO SessionFactoryImpl:155 - building session factory
    [java] 09:09:24,938 INFO SessionFactoryObjectFactory:82 - Not binding fact
    ory to JNDI, no JNDI name configured
    [java] 09:09:24,954 INFO SchemaValidator:99 - Running schema validator
    [java] 09:09:24,954 INFO SchemaValidator:107 - fetching database metadata
    [java] 09:09:24,954 INFO Configuration:1014 - processing extends queue
    [java] 09:09:24,954 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:09:24,954 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:09:24,954 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:09:24,985 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState
    : S1002
    [java] 09:09:24,985 ERROR JDBCExceptionReporter:72 - [Microsoft][ODBC SQL S
    erver Driver]Invalid Descriptor Index
    [java] 09:09:25,001 ERROR SchemaValidator:129 - Error closing connection
    [java] java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid transaction state
    [java] Initial SessionFactory creation failed.org.hibernate.exception.Gener
    icJDBCException: could not get table metadata: Child
    [java] java.lang.ExceptionInInitializerError
    [java] at HibernateUtil.<clinit>(Unknown Source)
    [java] at PCManager.listEvents(Unknown Source)
    [java] at PCManager.main(Unknown Source)
    [java] Caused by: org.hibernate.exception.GenericJDBCException: could not g
    et table metadata: Child
    [java] at org.hibernate.exception.SQLStateConverter.handledNonSpecificE
    xception(SQLStateConverter.java:91)
    [java] at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
    [java] at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
    [java] at sun.jdbc.odbc.JdbcOdbc.SQLDisconnect(JdbcOdbc.java:2988)
    [java] at sun.jdbc.odbc.JdbcOdbcDriver.disconnect(JdbcOdbcDriver.java:9
    80)
    [java] at sun.jdbc.odbc.JdbcOdbcConnection.close(JdbcOdbcConnection.jav
    a:739)
    [java] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal
    idator.java:125)
    [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm
    pl.java:299)
    [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
    tion.java:1145)
    [java] at HibernateUtil.<clinit>(Unknown Source)
    [java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateCon
    verter.java:79)
    [java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
    tionHelper.java:43)
    [java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
    tionHelper.java:29)
    [java] at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(
    DatabaseMetadata.java:100)
    [java] at org.hibernate.cfg.Configuration.validateSchema(Configuration.
    java:946)
    [java] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaVal
    idator.java:116)
    [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryIm
    pl.java:299)
    [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configura
    tion.java:1145)
    [java] ... 3 more
    [java] Caused by: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver
    ]Invalid Descriptor Index
    [java] at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
    [java] at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
    [java] at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3862)
    [java] at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultS
    et.java:5561)
    [java] at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.j
    ava:338)
    [java] at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.j
    ava:395)
    [java] at PCManager.listEvents(Unknown Source)
    [java] at PCManager.main(Unknown Source)
    [java] at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata
    .java:30)
    [java] at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(
    DatabaseMetadata.java:85)
    [java] ... 7 more
    [java] Exception in thread "main"
    [java] Java Result: 1
    BUILD SUCCESSFUL
    Total time: 4 seconds
    Name and version of the database you are using:
    Microsoft SQLServer2000
    The generated SQL (show_sql=true):
    When the program is run with "hbm2ddl.auto" property as create, I get the following output.
    C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc2\MyHibernate>ant run -Daction=store
    Buildfile: build.xml
    clean:
    [delete] Deleting directory C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    [mkdir] Created dir: C:\Documents and Settings\mirza\Desktop\hibernate-3.1rc
    2\MyHibernate\bin
    copy-resources:
    [copy] Copying 4 files to C:\Documents and Settings\mirza\Desktop\hibernate
    -3.1rc2\MyHibernate\bin
    compile:
    [javac] Compiling 5 source files to C:\Documents and Settings\mirza\Desktop\
    hibernate-3.1rc2\MyHibernate\bin
    run:
    [java] 09:12:54,820 INFO Environment:474 - Hibernate 3.1 rc2
    [java] 09:12:54,836 INFO Environment:489 - loaded properties from resource
    hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true, hibernate
    .cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.dial
    ect=org.hibernate.dialect.SQLServerDialect, hibernate.max_fetch_depth=1, hiberna
    te.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.
    substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.cac
    he.region_prefix=hibernate.test, hibernate.jdbc.batch_versioned_data=true, hiber
    nate.connection.pool_size=1}
    [java] 09:12:54,852 INFO Environment:519 - using java.io streams to persis
    t binary types
    [java] 09:12:54,852 INFO Environment:520 - using CGLIB reflection optimize
    r
    [java] 09:12:54,867 INFO Environment:550 - using JDK 1.4 java.sql.Timestam
    p handling
    [java] 09:12:54,946 INFO Configuration:1257 - configuring from resource: /
    hibernate.cfg.xml
    [java] 09:12:54,946 INFO Configuration:1234 - Configuration resource: /hib
    ernate.cfg.xml
    [java] 09:12:55,259 INFO Configuration:460 - Reading mappings from resourc
    e: PCMapping.hbm.xml
    [java] 09:12:55,400 INFO HbmBinder:266 - Mapping class: Parent -> Parent
    [java] 09:12:55,447 INFO HbmBinder:266 - Mapping class: Child -> Child
    [java] 09:12:55,447 INFO Configuration:1368 - Configured SessionFactory: n
    ull
    [java] 09:12:55,447 INFO Configuration:1014 - processing extends queue
    [java] 09:12:55,447 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:12:55,447 INFO HbmBinder:2233 - Mapping collection: Parent.child
    ren -> Child
    [java] 09:12:55,463 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:12:55,479 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:12:55,557 INFO DriverManagerConnectionProvider:41 - Using Hibern
    ate built-in connection pool (not for production use!)
    [java] 09:12:55,557 INFO DriverManagerConnectionProvider:42 - Hibernate co
    nnection pool size: 1
    [java] 09:12:55,557 INFO DriverManagerConnectionProvider:45 - autocommit m
    ode: false
    [java] 09:12:55,573 INFO DriverManagerConnectionProvider:80 - using driver
    : sun.jdbc.odbc.JdbcOdbcDriver at URL: jdbc:odbc:MySQL
    [java] 09:12:55,573 INFO DriverManagerConnectionProvider:86 - connection p
    roperties: {}
    [java] 09:12:55,651 INFO SettingsFactory:77 - RDBMS: Microsoft SQL Server,
    version: 08.00.0194
    [java] 09:12:55,667 INFO SettingsFactory:78 - JDBC driver: JDBC-ODBC Bridg
    e (SQLSRV32.DLL), version: 2.0001 (03.85.1117)
    [java] 09:12:55,682 INFO Dialect:100 - Using dialect: org.hibernate.dialec
    t.SQLServerDialect
    [java] 09:12:55,698 INFO TransactionFactoryFactory:31 - Using default tran
    saction strategy (direct JDBC transactions)
    [java] 09:12:55,714 INFO TransactionManagerLookupFactory:33 - No Transacti
    onManagerLookup configured (in JTA environment, use of read-write or transaction
    al second-level cache is not recommended)
    [java] 09:12:55,714 INFO SettingsFactory:125 - Automatic flush during befo
    reCompletion(): disabled
    [java] 09:12:55,714 INFO SettingsFactory:129 - Automatic session close at
    end of transaction: disabled
    [java] 09:12:55,729 INFO SettingsFactory:144 - Scrollable result sets: ena
    bled
    [java] 09:12:55,729 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): d
    isabled
    [java] 09:12:55,745 INFO SettingsFactory:160 - Connection release mode: au
    to
    [java] 09:12:55,745 INFO SettingsFactory:184 - Maximum outer join fetch de
    pth: 1
    [java] 09:12:55,745 INFO SettingsFactory:187 - Default batch fetch size: 1
    [java] 09:12:55,745 INFO SettingsFactory:191 - Generate SQL with comments:
    disabled
    [java] 09:12:55,745 INFO SettingsFactory:195 - Order SQL updates by primar
    y key: disabled
    [java] 09:12:55,745 INFO SettingsFactory:338 - Query translator: org.hiber
    nate.hql.ast.ASTQueryTranslatorFactory
    [java] 09:12:55,777 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTran
    slatorFactory
    [java] 09:12:55,792 INFO SettingsFactory:203 - Query language substitution
    s: {no='N', yes='Y'}
    [java] 09:12:55,792 INFO SettingsFactory:209 - Second-level cache: enabled
    [java] 09:12:55,792 INFO SettingsFactory:213 - Query cache: disabled
    [java] 09:12:55,792 INFO SettingsFactory:325 - Cache provider: org.hiberna
    te.cache.HashtableCacheProvider
    [java] 09:12:55,808 INFO SettingsFactory:228 - Optimize cache for minimal
    puts: disabled
    [java] 09:12:55,808 INFO SettingsFactory:233 - Cache region prefix: hibern
    ate.test
    [java] 09:12:55,808 INFO SettingsFactory:237 - Structured second-level cac
    he entries: disabled
    [java] 09:12:55,839 INFO SettingsFactory:257 - Echoing all SQL to stdout
    [java] 09:12:55,839 INFO SettingsFactory:264 - Statistics: disabled
    [java] 09:12:55,839 INFO SettingsFactory:268 - Deleted entity synthetic id
    entifier rollback: disabled
    [java] 09:12:55,839 INFO SettingsFactory:283 - Default entity-mode: POJO
    [java] 09:12:55,980 INFO SessionFactoryImpl:155 - building session factory
    [java] 09:12:56,325 INFO SessionFactoryObjectFactory:82 - Not binding fact
    ory to JNDI, no JNDI name configured
    [java] 09:12:56,341 INFO Configuration:1014 - processing extends queue
    [java] 09:12:56,341 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:12:56,341 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:12:56,341 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:12:56,356 INFO Configuration:1014 - processing extends queue
    [java] 09:12:56,356 INFO Configuration:1018 - processing collection mappin
    gs
    [java] 09:12:56,356 INFO Configuration:1027 - processing association prope
    rty references
    [java] 09:12:56,372 INFO Configuration:1049 - processing foreign key const
    raints
    [java] 09:12:56,372 INFO SchemaExport:153 - Running hbm2ddl schema export
    [java] 09:12:56,388 DEBUG SchemaExport:171 - import file not found: /import
    .sql
    [java] 09:12:56,388 INFO SchemaExport:180 - exporting generated schema to
    database
    [java] 09:12:56,403 DEBUG SchemaExport:283 -
    [java] alter table Child
    [java] drop constraint FK3E104FC976A59A
    [java] 09:12:56,466 DEBUG SchemaExport:283 -
    [java] drop table Child
    [java] 09:12:56,544 DEBUG SchemaExport:283 -
    [java] drop table Parent
    [java] 09:12:56,654 DEBUG SchemaExport:283 -
    [java] create table Child (
    [java] id numeric(19,0) identity not null,
    [java] name varchar(255) null,
    [java] parent_id numeric(19,0) null,
    [java] primary key (id)
    [java] )
    [java] 09:12:56,779 DEBUG SchemaExport:283 -
    [java] create table Parent (
    [java] id numeric(19,0) identity not null,
    [java] primary key (id)
    [java] )
    [java] 09:12:56,873 DEBUG SchemaExport:283 -
    [java] alter table Child
    [java] add constraint FK3E104FC976A59A
    [java] foreign key (parent_id)
    [java] references Parent
    [java] 09:12:56,952 INFO SchemaExport:200 - schema export complete
    [java] 09:12:56,952 WARN JDBCExceptionReporter:48 - SQL Warning: 5701, SQL
    State: 01000
    [java] 09:12:56,952 WARN JDBCExceptionReporter:49 - [Microsoft][ODBC SQL S
    erver Driver][SQL Server]Changed database context to 'master'.
    [java] 09:12:56,952 WARN JDBCExceptionReporter:48 - SQL Warning: 5703, SQL
    State: 01000
    [java] 09:12:56,952 WARN JDBCExceptionReporter:49 - [Microsoft][ODBC SQL S
    erver Driver][SQL Server]Changed language setting to us_english.
    [java] 09:12:56,983 INFO SessionFactoryImpl:432 - Checking 0 named queries
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Child
    [java] (name)
    [java] values
    [java] (?) select
    [java] scope_identity()
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Child
    [java] (name)
    [java] values
    [java] (?) select
    [java] scope_identity()
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Child
    [java] (name)
    [java] values
    [java] (?) select
    [java] scope_identity()
    [java] Hibernate:
    [java] insert
    [java] into
    [java] Parent
    [java] default
    [java] values
    [java] select
    [java] scope_identity()
    [java] Hibernate:
    [java] update
    [java] Child
    [java] set
    [java] parent_id=?
    [java] where
    [java] id=?
    [java] Hibernate:
    [java] update
    [java] Child
    [java] set
    [java] parent_id=?
    [java] where
    [java] id=?
    [java] Hibernate:
    [java] update
    [java] Child
    [java] set
    [java] parent_id=?
    [java] where
    [java] id=?
    [java] 09:12:57,390 INFO SessionFactoryImpl:831 - closing
    [java] 09:12:57,390 INFO DriverManagerConnectionProvider:147 - cleaning up
    connection pool: jdbc:odbc:MySQL
    BUILD SUCCESSFUL
    Total time: 5 seconds
    Debug level Hibernate log excerpt:
    Included in the above description.

    That's not the right mapping for the 1:m relationship in Hibernate.
    First of all, I believe the recommendation is to have a separate .hbm.xml file for each class, so you should have one for Parent and Child.
    Second, you'll find the proper syntax for a one-to-many relationship here:
    http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial.html#tutorial-associations
    See if those help.
    The tutorial docs for Hibernate are quite good. I'd recommend going through them carefully.
    %

Maybe you are looking for

  • Sound does not work correctly all the time, on youtube.

    So I have been having this issue for a while now, and I have tried everything to fix it on my own. My issue is sometimes you-tube videos will play about 1-2 sec of sound then stop, the video will buff all the way out and I can watch it but no sound w

  • Problem with scope, inside custom class

    I'm having trouble with the code below- can anybody explain why "class_obj" is undefined in my xml.onLoad handler? even though its available through out the class instance?

  • What is the best practice for developing web service?

    Hi All, I'm a newbee to web services... I was wondering what would be the best approach in developing a web service, using tools or programmatic approach? If I use WebLogic Workshop, am I tied to a vendor? Is it possible for me to develop web service

  • How to enable exporting video. newbie

    Hi all, I know this is elementary but have pity on me as I'm still a newbie. I have a sequence with a few audio tracks onto a video track. I want to File/export to a vimeo video file. When I pick export, it only allows me to export the audio.  I *kno

  • Download CS6 Extended

    How do I download the Photoshop CS6 Extended. The Adobe Download Assistant doesn't give it as a choice.