-->
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.  [ 1 post ] 
Author Message
 Post subject: Table create fails due to an "invalid identifier"
PostPosted: Wed Mar 30, 2005 1:59 pm 
Newbie

Joined: Tue Mar 29, 2005 2:02 pm
Posts: 3
Table fails to generate due to an "invalid identifier" error.

What is wrong?

-- I concocted a "post.hbm.xml" (i.e., "post" table) and "author.hbm.xml" (i.e., "author" table) and ran hbm2java to generate these tables ("post" and "author") to the "SCOTT" schema, in my Oracle database.

Unfortunately, the "author" table is created..., but, NOT the "post" table....why???

--One weird thing I noticed is that defined "datex" column (in "post.hbm.xml") does not seem to appear in the generated Oracle sql.

In otherwords, instead of "date datex", "date date" appears and seems to be causing the table create to fail.

Quote:
create table post (ID varchar2(255) not null, revision number(10,0) not null, title varchar2(100), summary varchar2(255), content clob, date date, authorID varchar2(255) not null, primary key (ID))


Thanks for any help!

sd


------------

Hibernate version:
2.1.8

Quote:
hibernate.properties:
hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'

hibernate.dialect net.sf.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.OracleDriver
hibernate.connection.username scott
hibernate.connection.password tiger
hibernate.connection.url jdbc:oracle:thin:@localhost:1521:dustygdb

hibernate.connection.pool_size 1
hibernate.proxool.pool_alias pool1
hibernate.show_sql true
hibernate.jdbc.batch_size 0
hibernate.jdbc.batch_versioned_data true
hibernate.jdbc.use_streams_for_binary true
hibernate.max_fetch_depth 1

hibernate.cache.region_prefix hibernate.test
hibernate.cache.use_query_cache true
hibernate.cache.provider_class net.sf.hibernate.cache.EhCacheProvider

Mapping documents:

-- "author.hbm.xml" --
Quote:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="blogger.Author" table="author">
<id name="id" type="string" column="ID">
<meta attribute="finder-method">findByID</meta>
<generator class="uuid.hex"/>
</id>
<property name="firstName" type="java.lang.String" column="first" length="100"/>
<property name="lastName" type="java.lang.String" column="last" length="100"/>
<property name="email" type="java.lang.String" column="email" length="100">
<meta attribute="finder-method">findByEmail</meta>
</property>
<!-- bi-directional one-to-many association to Post -->
<set name="posts" lazy="true" inverse="true" cascade="delete">
<key>
<column name="authorID"/>
</key>
<one-to-many class="blogger.Post"/>
</set>
</class>
</hibernate-mapping>


-- "post.hbm.xml" -- <?xml version="1.0"?>
Quote:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="blogger.Post" table="post">
<id name="id" type="string" column="ID">
<meta attribute="finder-method">findByID</meta>
<generator class="uuid.hex"/>
</id>
<version column="revision" name="revision"/>
<property name="title" type="string" column="title" length="100"/>
<property name="summary" type="string" column="summary" length="255"/>
<property name="content" type="text" column="content"/>
<property name="datex" type="timestamp" column="datex"/>
<many-to-one name="author" class="blogger.Author">
<!-- Used by code generator -->
<meta attribute="finder-method">findByAuthorID</meta>
<!-- Used as a DDL hint -->
<column name="authorID" not-null="true"/>
</many-to-one>
</class>
</hibernate-mapping>


-- "hbm2java_config.xml" -- <?xml version="1.0"?>
Quote:
<codegen>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
<generate
package="blogger.finder"
suffix="Finder"
renderer="net.sf.hibernate.tool.hbm2java.FinderRenderer"/>
</codegen>


Code between sessionFactory.openSession() and session.close():
example code:

Quote:
package blogger;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;

import net.sf.hibernate.tool.hbm2ddl.SchemaUpdate;

public class AppSession
{
static String fileSep = System.getProperty("file.separator");
public static SessionFactory sessionFactory;
public static Session getSession()
{
if (sessionFactory == null) initialization();
try
{
return sessionFactory.openSession();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
public static void initialization()
{
try
{
Configuration myConfiguration = new Configuration();
myConfiguration.addClass(Post.class);
myConfiguration.addClass(Author.class);
new SchemaUpdate(myConfiguration).execute(true, true);
sessionFactory = myConfiguration.buildSessionFactory();

}
catch (Exception e)
{
e.printStackTrace();
}
}

public static void main(String[] args)
{
initialization();
}
}


Full stack trace of any exception that occurs:
Quote:
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for date in class blogger.Post

at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182)

at net.sf.hibernate.mapping.Property.getGetter(Property.java:175)

at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:749)

at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:690)

at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)

at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)

at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)

at blogger.AppSession.initialization(AppSession.java:51)

at blogger.AppSession.getSession(AppSession.java:20)

at org.apache.jsp.jsp1_jsp._jspService(jsp1_jsp.java:52)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

at java.lang.Thread.run(Thread.java:534)

java.lang.NullPointerException

at blogger.AppSession.getSession(AppSession.java:23)

at org.apache.jsp.jsp1_jsp._jspService(jsp1_jsp.java:52)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

at java.lang.Thread.run(Thread.java:534)

java.lang.NullPointerException

at org.apache.jsp.jsp1_jsp._jspService(jsp1_jsp.java:53)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

at java.lang.Thread.run(Thread.java:534)


Name and version of the database you are using:
Oracle9i

The generated SQL (show_sql=true):
12:52:47,015 INFO Environment:483 - Hibernate 2.1.8

12:52:47,031 INFO Environment:517 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.OracleDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=scott, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:dustygdb, hibernate.show_sql=true, hibernate.connection.password=tiger, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}

12:52:47,046 INFO Environment:542 - using java.io streams to persist binary types

12:52:47,046 INFO Environment:543 - using CGLIB reflection optimizer

12:52:47,062 INFO Environment:572 - using JDK 1.4 java.sql.Timestamp handling

12:52:47,062 INFO Configuration:351 - Mapping resource: blogger/Post.hbm.xml

12:52:47,281 INFO Binder:229 - Mapping class: blogger.Post -> post

12:52:47,359 INFO Configuration:351 - Mapping resource: blogger/Author.hbm.xml

12:52:47,390 INFO Binder:229 - Mapping class: blogger.Author -> author

12:52:47,500 INFO Dialect:86 - Using dialect: net.sf.hibernate.dialect.OracleDialect

12:52:47,500 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)

12:52:47,500 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 1

12:52:47,531 INFO DriverManagerConnectionProvider:77 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:dustygdb

12:52:47,531 INFO DriverManagerConnectionProvider:78 - connection properties: {user=scott, password=tiger}

12:52:47,531 INFO SchemaUpdate:102 - Running hbm2ddl schema update

12:52:47,531 INFO SchemaUpdate:112 - fetching database metadata

12:52:48,015 INFO SchemaUpdate:127 - updating schema

12:52:48,015 INFO Configuration:641 - processing one-to-many association mappings

12:52:48,015 INFO Binder:1181 - Mapping collection: blogger.Author.posts -> post

12:52:48,015 INFO Configuration:650 - processing one-to-one association property references

12:52:48,015 INFO Configuration:675 - processing foreign key constraints

12:52:48,171 INFO TableMetadata:39 - table found: SCOTT.AUTHOR

12:52:48,171 INFO TableMetadata:40 - columns: [last, first, email, id]

12:52:48,171 INFO TableMetadata:41 - foreign keys: []

12:52:48,187 INFO TableMetadata:42 - indexes: [sys_c003063]

12:52:48,187 INFO DatabaseMetadata:82 - table not found: post

12:52:48,218 INFO DatabaseMetadata:82 - table not found: post

create table post (ID varchar2(255) not null, revision number(10,0) not null, title varchar2(100), summary varchar2(255), content clob, date date, authorID varchar2(255) not null, primary key (ID))

12:52:48,218 DEBUG SchemaUpdate:136 - create table post (ID varchar2(255) not null, revision number(10,0) not null, title varchar2(100), summary varchar2(255), content clob, date date, authorID varchar2(255) not null, primary key (ID))

12:52:48,234 ERROR SchemaUpdate:141 - Unsuccessful: create table post (ID varchar2(255) not null, revision number(10,0) not null, title varchar2(100), summary varchar2(255), content clob, date date, authorID varchar2(255) not null, primary key (ID))

12:52:48,234 ERROR SchemaUpdate:142 - ORA-00904: : invalid identifier


Debug level Hibernate log excerpt:
Quote:
(see above)

_________________
sd


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

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.