-->
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.  [ 7 posts ] 
Author Message
 Post subject: Totally baffled...
PostPosted: Sat Oct 25, 2003 9:22 pm 
Newbie

Joined: Tue Oct 21, 2003 12:06 pm
Posts: 12
I've finally gotten my generic database wrapper to execute queries, but for some reason this one is failing.

The row in the database is:

343, 307, COMPAQCC.908887732000.20031025205356428.PO

The mapping file is:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- com.stic.database.jdo.ProcessMap root -->
<class name="com.stic.database.jdo.ProcessMap" table="PROCESS_MAP">
<id name="id" type="long" column="ID">
<generator class="com.stic.database.access.IdGenerator"/>
</id>
<property name="flowId" column="FLOW_ID" type="long"/>
<property name="mailbagId" column="MAILBAG_ID" type="string"/>
</class>
</hibernate-mapping>

The mapped class is:

/*
* Created on Oct 23, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.stic.database.jdo;

/**
* @author <a href="http://boss.bekk.no/boss/middlegen/">Middlegen</a>
*
* @jdo.bean
* identity-type="datastore"
* @jdo.rdbmapping table="PROCESS_MAP"
*
* @jdo.finder todo...
*/
public class ProcessMap
{

// fields
/**
* The id field
* @jdo.field
* modifier="persistent"
* null-value="exception"
* primary-key="true"
* @jdo.rdbmapping column="ID"
*/
private long id;

/**
* The flowId field
* @jdo.field
* modifier="persistent"
* null-value="exception"
* @jdo.rdbmapping column="FLOW_ID"
*/
private long flowId;

/**
* The mailbagId field
* @jdo.field
* modifier="persistent"
* null-value="exception"
* @jdo.rdbmapping column="MAILBAG_ID"
*/
private java.lang.String mailbagId;

// relations

/**
* Constructs a new ProcessMapBean with only mandatory (non-nullable) parameters
* @param id the id value
* @param flowId the flowId value
* @param mailbagId the mailbagId value
*/
public ProcessMap(long id, long flowId, java.lang.String mailbagId)
{
setId(id);
setFlowId(flowId);
setMailbagId(mailbagId);
}

public ProcessMap()
{
}

/**
* Returns the id
*
* @return the id
*/
public long getId()
{
return id;
}

/**
* Sets the id
*
* @param long the new id
*/
public void setId(long newId)
{
id = newId;
}

/**
* Returns the flowId
*
* @return the flowId
*/
public long getFlowId()
{
return flowId;
}

/**
* Sets the flowId
*
* @param long the new flowId
*/
public void setFlowId(long newFlowId)
{
flowId = newFlowId;
}

/**
* Returns the mailbagId
*
* @return the mailbagId
*/
public java.lang.String getMailbagId()
{
return mailbagId;
}

/**
* Sets the mailbagId
*
* @param java.lang.String the new mailbagId
*/
public void setMailbagId(java.lang.String newMailbagId)
{
mailbagId = newMailbagId;
}

}

the query is:

String queryString = "from com.stic.database.jdo.ProcessMap as map where map.mailbagId = :mailbagId";
Query query = session.createQuery(queryString);
query = query.setString("mailbaxId", "COMPAQCC.908887732000.20031025205356428.PO");
List list = query.list();

log.debug("Found " + list.size() + " item(s)");

the output in the log is (the real log, not what's in the code fragements here):

2003-10-25 20:53:58,641 DEBUG [com.stic.database.access.DatabaseIterator] Preparing query = from com.stic.database.jdo.ProcessMap as map where map.mailbagId = :mailbagId
2003-10-25 20:53:58,641 DEBUG [com.stic.database.access.DatabaseIterator] Adding parameter = mailbagId with value = COMPAQCC.908887732000.20031025205356428.PO with column type = 1
2003-10-25 20:53:58,641 DEBUG [com.stic.database.access.DatabaseIterator] About to execute query...from com.stic.database.jdo.ProcessMap as map where map.mailbagId = :mailbagId
2003-10-25 20:53:58,641 DEBUG [com.stic.database.access.DatabaseIterator] Named parameter[0] = mailbagId
2003-10-25 20:53:58,641 DEBUG [com.stic.database.access.DatabaseIterator] Found 0 item(s).

The database schema is:

create table PROCESS_MAP (
id BIGINT not null,
flow_id BIGINT not null,
mailbag_id varchar(100) not null,
primary key(id)
);

FYI even the call:

session.find("from com.stic.database.jdo.ProcessMap");

returns no rows.

What's wrong? I can't figure it out and I've been scrathing my head on this for more than a few hours now...

Thanks in advance,
Chuck


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 25, 2003 11:36 pm 
Newbie

Joined: Tue Oct 21, 2003 12:06 pm
Posts: 12
Here's some more information...

The process map record was written to the database earlier in the same APPLICATION run, but not in the same SESSION as the one doing the query.

In my application, I do the following...
SessionFactory sFac...

Session session = sFac.openSession();
session.save(Object);
session.flush();
session.close();

I've also found that if I shut down JBoss and restart it, the query works just fine.

The confusing part of this is that I save other object to other tables in the database and I'm able to do a query on them in the same APPLICATION run...I used to use session.beginTransactio() and transaction.commit() but using these in the application threw an SQLException on the commit...

anyone have any clues?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 12:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Looks like a typo to me.

Quote:
query = query.setString("mailbaxId", "COMPAQCC.908887732000.20031025205356428.PO");


The parameter name is not mailbaxId it should be mailbagId.

BTW: Noticed you using Middlegen hibernate plugin for hbms and POJOs are generated using the JDO plugin. Is it really close enough that you don't have to modifiy the POJOs all that much to work? Also, why not use hbm2java is does work well.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 1:21 pm 
Newbie

Joined: Tue Oct 21, 2003 12:06 pm
Posts: 12
David,

The typo was in the posting, not in my code. I didn't do a direct cut/paste as my lookups into the database are done by a class that hides the database/obj. rel. mapping tool.

I'll give the hbm2java tool a try as I did need to do a lil modification to the POJO's that Middlegen generated.

I'm also in the process of moving to EJB's and using Hibernate for my CMP. I think the issue here is that I'm not really getting the data committed to the database. Either that, or the writing is happening in one container and the reading/query is happening in another, but I thought that was the whole reason for the database?

Anyway, something is not right here, so I'm going to scratch my head and work on it a bit longer and see if I can get it resolved. If I can't, the move to EJB's will be accelerated as I think that may solve my problems.

Thanks,
Chuck


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 6:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If you are not currently using EJB then you are not using CMT so you will have to call the transaction operations to commit the data to the database.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 6:25 pm 
Newbie

Joined: Tue Oct 21, 2003 12:06 pm
Posts: 12
But I can't call the transaction operations as when I do I get an SQLException with the explanation that I can't call commit on a managed connection, or something like that.

Chuck


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 5:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hmmmm......Maybe we don't have enough information as some of what has been said is in conflict. There are some examples of SLSBs usings CMT so this would be a good start.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.