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

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: Select error in insert command! (it is not for one to many)
PostPosted: Mon Aug 13, 2007 9:46 am 
Newbie

Joined: Mon Aug 13, 2007 9:27 am
Posts: 12
{"ORA-00928: missing SELECT keyword\n" } in insert command!

error message :
{"could not insert: [TSSDataAccess.DTO.SuggesterInfoDTO#1][SQL: INSERT INTO SUGGESTERINFO (index, fullName, personelNo, education, staff, organizationalUnit, age, precedent, collaborationPercent, suggestionid, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]" }

what do you think about this?!!!

dto classes:

SuggestionDTO :
Code:
using System;
using System.Collections;

namespace TSSDataAccess.DTO
{
   /// <summary>
   /// Summary description for SuggestionForm.
   /// </summary>
   public class SuggestionDTO : GenericDTO
   {
      public SuggestionDTO()
      {
         //
         // TODO: Add constructor logic here
         //
      }


      public SuggestionDTO(string _title, DateTime _creationTime, string _currentMethodDescription, string _currentMethodDifficulty, string _suggestedMethodDescription, string _suggestedMethodBenefits, IList _suggesters, IList _results, IList _attachments, string _thriftPrice)
      {
         this._title = _title;
         this._creationTime = _creationTime;
         this._currentMethodDescription = _currentMethodDescription;
         this._currentMethodDifficulty = _currentMethodDifficulty;
         this._suggestedMethodDescription = _suggestedMethodDescription;
         this._suggestedMethodBenefits = _suggestedMethodBenefits;
         this._suggesters = _suggesters;
         this._results = _results;
         this._attachments = _attachments;
         this._thriftPrice = _thriftPrice;
      }

      public enum Status
      {
         Draft = 1,
         Saved = 2
      }

      private string _title;
      private DateTime _creationTime;
      private string _currentMethodDescription;
      private string _currentMethodDifficulty;
      private string _suggestedMethodDescription;
      private string _suggestedMethodBenefits;
      private IList _suggesters;
      private IList _results;
      private IList _attachments;
        private string _thriftPrice;
      private string _otherBenefits;
      private Status _status;


      public virtual string title
      {
         get { return _title; }
         set
         {
            _title = value;

            if(_title == string.Empty)
               _title = null;
         }
      }

      public virtual DateTime creationTime
      {
         get { return _creationTime; }
         set { _creationTime = value; }
      }

      public virtual string currentMethodDescription
      {
         get { return _currentMethodDescription; }
         set
         {
            _currentMethodDescription = value;

            if(_currentMethodDescription == string.Empty)
               _currentMethodDescription = null;}
      }

      public virtual string currentMethodDifficulty
      {
         get { return _currentMethodDifficulty; }
         set
         {
            _currentMethodDifficulty = value;

            if(_currentMethodDifficulty == string.Empty)
               _currentMethodDifficulty = null; }
      }

      public virtual string suggestedMethodDescription
      {
         get { return _suggestedMethodDescription; }
         set
         {
            _suggestedMethodDescription = value;

            if(_suggestedMethodDescription == string.Empty)
               _suggestedMethodDescription = null;}
      }

      public virtual string suggestedMethodBenefits
      {
         get { return _suggestedMethodBenefits; }
         set
         {
            _suggestedMethodBenefits = value;

            if(_suggestedMethodBenefits == string.Empty)
               _suggestedMethodBenefits = null; }
      }

      public virtual IList suggesters
      {
         get { return _suggesters; }
         set { _suggesters = value; }
      }

      public virtual IList results
      {
         get { return _results; }
         set { _results = value; }
      }

      public virtual IList attachments
      {
         get { return _attachments; }
         set { _attachments = value; }
      }

      public virtual string thriftPrice
      {
         get { return _thriftPrice; }
         set
         {
            _thriftPrice = value;

            if(_thriftPrice == string.Empty)
               _thriftPrice = null; }
      }

      public virtual string otherBenefits
      {
         get { return _otherBenefits; }
         set
         {
            _otherBenefits = value;

            if(_otherBenefits == string.Empty)
               _otherBenefits = null; }
      }

      public virtual int status
      {
         get { return (int)_status; }
         set { _status = (Status)value; }
      }

      public virtual Status get_Status()
      {
         return _status;
      }

      public virtual void set_Status(Status status)
      {
         _status = status;
      }
   }
}


SuggesterInfoDTO :
Code:
using System;

namespace TSSDataAccess.DTO
{
   /// <summary>
   /// Summary description for SuggesterInfoDTO.
   /// </summary>
   public class SuggesterInfoDTO : GenericDTO
   {
      public SuggesterInfoDTO()
      {
         //
         // TODO: Add constructor logic here
         //
      }

//
//      public SuggesterInfoDTO(int _index, string _fullName, string _personelNo, string _education, string _staff, string _organizationalUnit, string _age, string _precedent, int _collaborationPercent)
//      {
//         this._index = _index;
//         this._fullName = _fullName;
//         this._personelNo = _personelNo;
//         this._education = _education;
//         this._staff = _staff;
//         this._organizationalUnit = _organizationalUnit;
//         this._age = _age;
//         this._precedent = _precedent;
//         this._collaborationPercent = _collaborationPercent;
//      }

      private int _index;
      private string _fullName;
      private string _personelNo;
      private string _education;
      private string _staff;
      private string _organizationalUnit;
      private string _age;
      private string _precedent;
      private int _collaborationPercent;
      private SuggestionDTO _suggestion;


      public virtual int index
      {
         get { return _index; }
         set { _index = value; }
      }

      public virtual string fullName
      {
         get { return _fullName; }
         set
         {
            _fullName = value;

            if(_fullName == string.Empty)
               _fullName = null; }
      }

      public virtual string personelNo
      {
         get { return _personelNo; }
         set
         {
            _personelNo = value;

            if(_personelNo == string.Empty)
               _personelNo = null; }
      }

      public virtual string education
      {
         get { return _education; }
         set
         {
            _education = value;

            if(_education == string.Empty)
               _education = null; }
      }

      public virtual string staff
      {
         get { return _staff; }
         set
         {
            _staff = value;

            if(_staff == string.Empty)
               _staff = null; }
      }

      public virtual string organizationalUnit
      {
         get { return _organizationalUnit; }
         set
         {
            _organizationalUnit = value;

            if(_organizationalUnit == string.Empty)
               _organizationalUnit = null;}
      }

      public virtual string age
      {
         get { return _age; }
         set
         {
            _age = value;

            if(_age == string.Empty)
               _age = null; }
      }

      public virtual string precedent
      {
         get { return _precedent; }
         set
         {
            _precedent = value;

            if(_precedent == string.Empty)
               _precedent = null; }
      }

      public virtual int collaborationPercent
      {
         get { return _collaborationPercent; }
         set { _collaborationPercent = value; }
      }

      public virtual SuggestionDTO suggestion
      {
         get { return _suggestion; }
         set { _suggestion = value; }
      }
   }
}


SuggestionResultDTO :
Code:
using System;

namespace TSSDataAccess.DTO
{
   /// <summary>
   /// Summary description for ImprovementDTO.
   /// </summary>
   public class SuggestionResultDTO : GenericDTO
   {
      public SuggestionResultDTO()
      {
         //
         // TODO: Add constructor logic here
         //
      }

      public enum Type
      {
         Thrift = 1,
         Improvement = 2,
         correction = 3,
         addition = 4
      }

      private string _title;
      private Type _type;


      public virtual string title
      {
         get { return _title; }
         set
         {
            _title = value;

            if(_title == string.Empty)
               _title = null;
         }
      }

      public virtual int type
      {
         get { return (int)_type; }
         set { _type = (Type)value; }
      }
   }
}


and related mapping files:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="TSSDataAccess.DTO.SuggestionDTO, TSSDataAccess" table="suggestion" dynamic-update="true">
      <id name="id" column="id" unsaved-value="0">
         <generator class="increment">
            </generator>
      </id>
      
      <property name="title" column="title" not-null="false" length="512" />
      <property name="creationTime" column="CREATIONTIME" not-null="false" type="DateTime" />
      <property name="currentMethodDescription" column="currentMethodDescription" not-null="false" />
      <property name="currentMethodDifficulty" column="currentMethodDifficulty" not-null="false" />
      <property name="suggestedMethodDescription" column="suggestedMethodDescription" not-null="false" />
      <property name="suggestedMethodBenefits" column="suggestedMethodBenefits" not-null="false" />
      <property name="thriftPrice" column="thriftPrice" not-null="false" length="1024" />
      <property name="otherBenefits" column="otherBenefits" not-null="false" length="1024" />
      
      <bag name="results" table="suggestion_mm_result" lazy="false" cascade="all">
         <key>
            <column name="suggestionid" not-null="true"/>
         </key>
         <many-to-many class="TSSDataAccess.DTO.SuggestionResultDTO, TSSDataAccess">
             <column name="resultid" not-null="true"/>
         </many-to-many>
      </bag>
      
      <bag name="suggesters" cascade="all">
         <key column="suggestionid"/>
         <one-to-many class="TSSDataAccess.DTO.SuggesterInfoDTO, TSSDataAccess"/>
      </bag>
      
      
   </class>
</hibernate-mapping>


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="TSSDataAccess.DTO.SuggesterInfoDTO, TSSDataAccess" table="SUGGESTERINFO" dynamic-update="true">
      <id name="id" column="id" unsaved-value="0">
         <generator class="increment">
            </generator>
      </id>
      
      <property name="index" column="index" not-null="false" />
      <property name="fullName" column="fullName" not-null="false" length="512" />
      <property name="personelNo" column="personelNo" not-null="false" length="512" />
      <property name="education" column="education" not-null="false" />
      <property name="staff" column="staff" not-null="false" length="512" />
      <property name="organizationalUnit" column="organizationalUnit" not-null="false" length="512" />
      <property name="age" column="age" not-null="false" />
      <property name="precedent" column="precedent" not-null="false" />
      <property name="collaborationPercent" column="collaborationPercent" not-null="false" />
      
      <many-to-one name="suggestion" class="TSSDataAccess.DTO.SuggestionDTO, TSSDataAccess" column="suggestionid" cascade="none" unique="false"/>
      
   </class>
</hibernate-mapping>


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="TSSDataAccess.DTO.SuggestionResultDTO, TSSDataAccess" table="suggestionresult" dynamic-update="true">
      <id name="id" column="id" unsaved-value="0">
         <generator class="increment">
            </generator>
      </id>
      
      <property name="title" column="title" not-null="false" />
      <property name="type" column="type" not-null="false" />
      
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 10:18 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hi,

Turn on SQL logging by adding the following line to you configuration file:

Code:
<property name="show_sql">true</property>


And watch the output: this will show you the SQL that 's being sent to the database. I'm pretty sure the problem has something to do with the id generator 'increment'.

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 10:45 am 
Newbie

Joined: Mon Aug 13, 2007 9:27 am
Posts: 12
if you want to fill a column in each row on insert by a trigger, what you will do with :

Code:
      <id name="id" column="id" unsaved-value="0">
         <generator class="increment">
            </generator>
      </id>


what kind of generator class, should I use ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 11:04 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Ah, the Id is assigned by a trigger ? There's no corresponding generator for that.

You might consider removing the trigger and let NHibernate take care of incrementing the Id for you (f.e. by using a sequence).

If not, you might consider implementing your own generator. Have a look at the following post:
http://forum.hibernate.org/viewtopic.php?t=973262

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 7:15 am 
Newbie

Joined: Mon Aug 13, 2007 9:27 am
Posts: 12
xasp wrote:
Hi,

Turn on SQL logging by adding the following line to you configuration file:

Code:
<property name="show_sql">true</property>


And watch the output: this will show you the SQL that 's being sent to the database. I'm pretty sure the problem has something to do with the id generator 'increment'.



I can't turn on sql debuging :( I can't see any sql statement in output window. is it possible this problem was because of my Visual Studio settings ???


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 7:28 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hello,

That's quite strange.

You can set this also through code before the creation of your SessionFactory:
Code:
Configuration cfg = new Configuration();
cfg.Configure(<assembly>, <config file>);
cfg.Properties["hibernate.show_sql"] = "true";
...
Factory = cfg.BuildSessionFactory();

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 7:33 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hello again,

In VS2005 there's a setting (under Options -> Debugging) that says 'redirect all output window text to immediate window'. If that's checked, this might be the cause ?

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 9:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
You also need to configure log4net. See docs for details.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 6:02 am 
Newbie

Joined: Mon Aug 13, 2007 9:27 am
Posts: 12
xasp wrote:
Hello again,

In VS2005 there's a setting (under Options -> Debugging) that says 'redirect all output window text to immediate window'. If that's checked, this might be the cause ?


I am using VS2003! where is this option in this version of VS? I think this is main problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 6:14 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hello,

I have no idea.

Maybe you'd better try a

Code:
Console.WriteLine("hello");


somewhere in your application, just to make sure it's that setting that is causing you trouble. If you see the 'hello' appearing in the Output window, the problem of the SQL not showing will be located somewhere else.

Let me (us) know what the result is.

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 6:18 am 
Newbie

Joined: Mon Aug 13, 2007 9:27 am
Posts: 12
xasp wrote:
Hello,

I have no idea.

Maybe you'd better try a

Code:
Console.WriteLine("hello");


somewhere in your application, just to make sure it's that setting that is causing you trouble. If you see the 'hello' appearing in the Output window, the problem of the SQL not showing will be located somewhere else.

Let me (us) know what the result is.


did not work! problem is just this! VS does not assume output window as console!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 10:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
Configure log4net in your app:
http://www.hibernate.org/hib_docs/nhibe ... on-logging

Add either the ConsoleAppender or the TraceAppender (forgot which one):
http://logging.apache.org/log4net/relea ... mples.html

Set log level to "DEBUG". And you already know to configure hibernate.show_sql to true.

_________________
Karl Chu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


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

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