No data type for node:

Status
Nicht offen für weitere Antworten.
G

Guest

Gast
Hallo!
Ich habe ein Hibernate Project geschrieben und erhalte aus der log4j prop folgenden Error:

No data type for node: org.hibernate.hql.ast.IdentNode
+-[ALIAS_REF] IdentNode: 'ID' {alias=ID, no from element}

Kann mir das jemand erklären?
 

byte

Top Contributor
Irgendein HQL-Statement ist fehlerhaft. Mehr kann man dazu nicht sagen. Der gesamte Stacktrace wäre hier interessant.
 
G

Guest

Gast
Code:
Session session = null;

		try
		{
			// This step will read hibernate.cfg.xml and prepare hibernate for
			// use
			SessionFactory sessionFactory = new Configuration().configure()
					.buildSessionFactory();
			session = sessionFactory.openSession();

			// Create Select Clause HQL
			String SQL_QUERY = "Select ID," + "GKASTIME," + "REVERSEINDICATOR,"
					+ "RESULT," + "ERRORID," + "COMPANY,"
					+ "EXTERNALTRANSACTIONID," + "COUNTRY," + "BELEGDATUM,"
					+ "BARCODE," + "CURRENCY," + "AMOUNT," + "TRANSACTIONTYPE,"
					+ "OLDBALANCE," + "NEWBALANCE," + "USERCARDID,"
					+ "AUTHORISATIONCODE," + "IP," + "CONVERSIONRATE"
					+ " from Cardtransaction";
			Query query = session.createQuery(SQL_QUERY);
			for (Iterator it = query.iterate(); it.hasNext();)
			{
				Object [] row = (Object []) it.next();
				System.out.println("ID: " + row[0]);
				System.out.println("Name: " + row[1]);
				System.out.println("Amount: " + row[2]);
			}

			session.close();
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}
		finally
		{
		}

Der StackTrace gibt nur Infos aus und dann eben dieses :(
Muss da irgendwie der Schema name vor oder so???
 
G

Guest

Gast
ich poste den ST mal:
Code:
INFO  - Hibernate 3.0rc1
INFO  - hibernate.properties not found
INFO  - using CGLIB reflection optimizer
INFO  - using JDK 1.4 java.sql.Timestamp handling
INFO  - configuring from resource: /hibernate.cfg.xml
INFO  - Configuration resource: /hibernate.cfg.xml
INFO  - Mapping resource: webreporting.hbm.xml
INFO  - Mapping class: cas.webreporting.mapping.Cardtransaction -> CARDTRANSACTION
INFO  - Configured SessionFactory: null
INFO  - processing extends queue
INFO  - processing collection mappings
INFO  - processing association property references
INFO  - processing foreign key constraints
INFO  - Using dialect: org.hibernate.dialect.DB2Dialect
INFO  - Default batch fetch size: 1
INFO  - Generate SQL with comments: disabled
INFO  - Order SQL updates by primary key: disabled
INFO  - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO  - Using ASTQueryTranslatorFactory
INFO  - Query language substitutions: {}
INFO  - Using Hibernate built-in connection pool (not for production use!)
INFO  - Hibernate connection pool size: 5
INFO  - autocommit mode: false
INFO  - using driver: com.ibm.db2.jcc.DB2Driver at URL: jdbc:db2://bla.de:50000/TGP
INFO  - connection properties: {user=bla, password=****}
INFO  - Scrollable result sets: enabled
INFO  - JDBC3 getGeneratedKeys(): enabled
INFO  - Using default transaction strategy (direct JDBC transactions)
INFO  - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO  - Automatic flush during beforeCompletion(): disabled
INFO  - Automatic session close at end of transaction: disabled
INFO  - Cache provider: org.hibernate.cache.EhCacheProvider
INFO  - Second-level cache: enabled
INFO  - Optimize cache for minimal puts: disabled
INFO  - Structured second-level cache entries: enabled
INFO  - Query cache: disabled
INFO  - Echoing all SQL to stdout
INFO  - Statistics: disabled
INFO  - Deleted entity synthetic identifier rollback: disabled
INFO  - Default entity-mode: pojo
INFO  - building session factory
WARN  - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/hibernate/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
WARN  - Could not find configuration [mapping.Cardtransaction]; using defaults.
INFO  - Not binding factory to JNDI, no JNDI name configured
INFO  - Using dialect: org.hibernate.dialect.DB2Dialect
INFO  - Using Hibernate built-in connection pool (not for production use!)
INFO  - Hibernate connection pool size: 5
INFO  - autocommit mode: false
INFO  - using driver: com.ibm.db2.jcc.DB2Driver at URL: jdbc:db2://gkasdb.bla.de:50000/TGP
INFO  - connection properties: {user=bla, password=****}
INFO  - Running hbm2ddl schema update
INFO  - fetching database metadata
INFO  - updating schema
INFO  - processing extends queue
INFO  - processing collection mappings
INFO  - processing association property references
INFO  - processing foreign key constraints
INFO  - table found: DGPUSR.CARDTRANSACTION
INFO  - columns: [result, errorid, oldbalance, authorisationcode, reverseindicator, transaction, belegdatum, usercardid, transactiontype, barcode, ip, country, currency, id, amount, companyid, conversionrate, gkastime, newbalance, externaltransactionid]
INFO  - foreign keys: []
INFO  - indexes: [i_cardtx_gkastime, i_cardtx_extid, sql070711103503910, i_cardtx_barcode]
INFO  - schema update complete
INFO  - cleaning up connection pool: jdbc:db2://bla.de:50000/TGP
INFO  - Checking 0 named queries
INFO  - cleaning up connection pool: jdbc:db2://bla.de:50000/TGP
No data type for node: org.hibernate.hql.ast.IdentNode 
 +-[ALIAS_REF] IdentNode: 'ID' {alias=ID, no from element}
 
S

SlaterB

Gast
nicht so kompliziert, in solchen Situationen immer einfachere Querys bauen:
Select ID from Cardtransaction

geht das? wenn ja, dann weitere Felder, ruhig auch mit etwas mehr Leerzeichen,
ansonsten nachschauen ob ID in Cardtransaction gemappt ist, welcher Datentyp, ob das zur DB passt usw.

ist das eigentlich HQL oder SQL? bei HQL sollte der String nicht SQL heißen, von allgemeinen Benennungskonventionen ganz abgesehen
 
S

SlaterB

Gast
ok, ich bekomme die gleiche Exception wenn ich
select xyz from [sinnvoller Klassenname]
schreibe,

selbst Groß-/ Kleinschreibung ist wichtig
 
G

Guest

Gast
JA id ist glaub ich in Cardtransaction gemappt oder?:
Bekomme bei final String selectAllQuery = "Select ID from Cardtransaction";

die gleiche Fehlermeldung.

Id ist in der DB der PK....muss ich das noch irgendwoi angeben ausser in der xml als:


Code:
<id name="id" type="integer" column="ID">
			<generator class="increment" />
		</id>
Code:
public class Cardtransaction
{
	private Integer	id;
	private Integer	amount;
	private Integer	transaction;
	private Integer	oldBalance;
	private Integer	newBalance;
	private Integer	usercardid;
	private Integer	reverseIndicator;
	private Integer	result;
	private Integer	companyId;
	private String	gkasTime;
	private String	country;
	private String	belegDatum;
	private String	errorID;
	private String	currency;
	private String	authorisationcode;
	private String	ip;
	private Long	externalTransactionId;
	private Long	barcode;
	private Long	conversionRate;

	public Integer getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}

	public Integer getAmount()
	{
		return amount;
	}

	public void setAmount(Integer amount)
	{
		this.amount = amount;
	}

	public Integer getTransaction()
	{
		return transaction;
	}

	public void setTransaction(Integer transaction)
	{
		this.transaction = transaction;
	}

	public Integer getOldBalance()
	{
		return oldBalance;
	}

	public void setOldBalance(Integer oldBalance)
	{
		this.oldBalance = oldBalance;
	}

	public Integer getNewBalance()
	{
		return newBalance;
	}

	public void setNewBalance(Integer newBalance)
	{
		this.newBalance = newBalance;
	}

	public Integer getUsercardid()
	{
		return usercardid;
	}

	public void setUsercardid(Integer usercardid)
	{
		this.usercardid = usercardid;
	}

	public Integer getReverseIndicator()
	{
		return reverseIndicator;
	}

	public void setReverseIndicator(Integer reverseIndicator)
	{
		this.reverseIndicator = reverseIndicator;
	}

	public Integer getResult()
	{
		return result;
	}

	public void setResult(Integer result)
	{
		this.result = result;
	}

	public Integer getCompanyId()
	{
		return companyId;
	}

	public void setCompanyId(Integer companyId)
	{
		this.companyId = companyId;
	}

	public String getGkasTime()
	{
		return gkasTime;
	}

	public void setGkasTime(String gkasTime)
	{
		this.gkasTime = gkasTime;
	}

	public String getCountry()
	{
		return country;
	}

	public void setCountry(String country)
	{
		this.country = country;
	}

	public String getBelegDatum()
	{
		return belegDatum;
	}

	public void setBelegDatum(String belegDatum)
	{
		this.belegDatum = belegDatum;
	}

	public String getErrorID()
	{
		return errorID;
	}

	public void setErrorID(String errorID)
	{
		this.errorID = errorID;
	}

	public String getCurrency()
	{
		return currency;
	}

	public void setCurrency(String currency)
	{
		this.currency = currency;
	}

	public String getAuthorisationcode()
	{
		return authorisationcode;
	}

	public void setAuthorisationcode(String authorisationcode)
	{
		this.authorisationcode = authorisationcode;
	}

	public String getIp()
	{
		return ip;
	}

	public void setIp(String ip)
	{
		this.ip = ip;
	}

	public Long getExternalTransactionId()
	{
		return externalTransactionId;
	}

	public void setExternalTransactionId(Long externalTransactionId)
	{
		this.externalTransactionId = externalTransactionId;
	}

	public Long getBarcode()
	{
		return barcode;
	}

	public void setBarcode(Long barcode)
	{
		this.barcode = barcode;
	}

	public Long getConversionRate()
	{
		return conversionRate;
	}

	public void setConversionRate(Long conversionRate)
	{
		this.conversionRate = conversionRate;
	}
}
 
S

SlaterB

Gast
Groß-/ Kleinschreibung ist wichtig:

Select id from Cardtransaction

statt

Select ID from Cardtransaction


> muss ich das noch irgendwoi angeben ausser in der xml als

gut dass du erstmal 20 weitere Attribute anlegst und in deine Querys schreibst, ohne anscheinend das Lesen und Schreiben einfach nur der Id getestet zu haben?
 
G

Gast

Gast
da scheint was mit der id nicht zu stimmen.
habe jetzt die "überflüssigen" Attribute entfern und id klein geschrieben
Fehlermeldung ist die gleiche:
No data type for node: org.hibernate.hql.ast.IdentNode
\-[ALIAS_REF] IdentNode: 'id' {alias=id, no from element}
 
S

SlaterB

Gast
tja, das ist hart, hätte so gut gepasst ;)

funktioniert eine Query 'from Cardtransaction'?
damit solltest du eine Liste von Cardtransaction bekommen,
Speichern dürftest du ja kennen oder kannst du auch in SQL extern machen,

werden dort Cardtransaction-Objekte mit den richtigen Ids zurückgegeben?
dann sollte ja das Mapping stimmen,
aber warum nun id nicht geht?..
 
G

Guest

Gast
das funktioniert:

gibts denn in hsql sowas wie select * from Cardtransaction???

Wieso geht das mit der ID nich :(

Code:
package cas.webreporting.reading;

import java.util.Iterator;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * @author Deepak Kumar
 * 
 * [url]http://www.roseindia.net[/url] HQL Select Clause Example
 */
public class SelectCardTransaction
{
	public void readInsurance()
	{
		Session session = null;
		final String selectAllQuery = "Select count(*) from Cardtransaction";

		try
		{
			// This step will read hibernate.cfg.xml and prepare hibernate for
			// use
			SessionFactory sessionFactory = new Configuration().configure()
					.buildSessionFactory();
			session = sessionFactory.openSession();

			// Create Select Clause HQL
			String SQL_QUERY = selectAllQuery;
			Query query = session.createQuery(SQL_QUERY);
			for (Iterator it = query.iterate(); it.hasNext();)
			{
				Integer row = (Integer) it.next();
				System.out.println(row);
				// System.out.println("ID: " + row[0]);
				// System.out.println("Name: " + row[1]);
				// System.out.println("Amount: " + row[2]);
			}

			session.close();
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}
		finally
		{
		}
	}

	public void readContact()
	{
		Session session = null;

		try
		{
			// This step will read hibernate.cfg.xml and prepare hibernate for
			// use
			SessionFactory sessionFactory = new Configuration().configure()
					.buildSessionFactory();
			session = sessionFactory.openSession();

			// Create Select Clause HQL
			String SQL_QUERY = "Select contact.id,contact.firstName,"
					+ "contact.lastName,contact.email from Contact contact";
			Query query = session.createQuery(SQL_QUERY);
			for (Iterator it = query.iterate(); it.hasNext();)
			{
				Object [] row = (Object []) it.next();
				System.out.println("ID: " + row[0]);
				System.out.println("Name: " + row[1]);
				System.out.println("Lastname: " + row[2]);
				System.out.println("Email: " + row[3]);
			}

			session.close();
		}
		catch (Exception e)
		{
			System.out.println(e.getMessage());
		}
		finally
		{
		}
	}

	public static void main(String [] args)
	{
		SelectCardTransaction app = new SelectCardTransaction();
		app.readInsurance();
		// app.readContact();
	}
}
 
S

SlaterB

Gast
count(*) muss ja auch keine Attribute laden,
das ist noch nicht ganz hilfreich

> select * from Cardtransaction

wozu?
schreibe einfach
from Cardtransaction
das geht, dann bekommst du schöne Cardtransaction-Objekte,
du willst hoffentlich nicht alle Attribute einzeln in einem Object[]..
 
Status
Nicht offen für weitere Antworten.

Ähnliche Java Themen


Oben