another beginner orm question

2010-01-14 Thread Mark Fuqua MdProfinish

Ok, got past last problem (thanks dave) and have uncommented the code on
index.cfm.  I followed the example on Manju's blog entitled Coldfusion-ORM:
Define One-to-Many and Many to One Relationships.  The article was for one
related table, mine is for three.  I used the built-in Apache database.  The
orm is creating the tables, though it doesn't seem to be reflecting my
latest changes.  Anyway, the code is below the error. 

 

Thanks,

 

Mark

 

ids for this class must be manually assigned before calling save(): Emails 

Root cause :org.hibernate.id.IdentifierGenerationException: ids for this
class must be manually assigned before calling save(): Emails   The error
occurred in C:\ColdFusion9\wwwroot\Orm\index.cfm: line 48

46 :   */

47 :   

48 :   EntitySave(newContact);

49 :

50 :   

 

 

Code for index.cfm (just a test for learning):

 

 





/*

Create a Contact with one address, one phone number
and one email address

*/



newContact = new Contacts();

newContact.setFirstName("Mark");

newContact.setLastName("Fuqua");



newAddress = new Addresses();

newAddress.setAddressDescription("2301 Mount Carmel
Road");

newAddress.setCity("Parkton");

newAddress.setState("MD");

newAddress.setZip("21120");



newEmail = new Emails();

newEmail.setEmailDescription("Work Email");

newEmail.setEmail("m...@mdprofinish.com");



newPhoneNumber = new PhoneNumbers();

newPhoneNumber.setPhoneDescription("Cell");

newPhoneNumber.setPhoneNumber("410-215-7356");



/*

Associate the Addresses, Emails and
PhoneNumbers with Contacts

*/



newContact.addaddresses(newAddress);

newContact.addEmails(newEmail);

newContact.addphoneNumbers(newPhoneNumber);



/*

Establish the relationship from the
other side

*/



newPhoneNumber.setContacts(newContact);

newAddress.setContacts(newContact);

newEmail.setContacts(newContact);



/*

Save new Contacts, email, address, phone
info should be saved as well

*/



EntitySave(newContact);





DisplayContacts();   



  




~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329681
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


orm beginner

2010-01-14 Thread Mark Fuqua MdProfinish

Trying to get my head wrapped around the new orm features.not doing well J.

 

I used an example I got from Manju's blog.trying to get one to many
relationships working.  I set up a Contacts.cfc with three one to many cfc's
(emails, addresses, phoneNumbers).  Then I created an index.cfm to set
things up and display results. I got an error.  So I commented out all the
code on index.cfm and tried again.same error.  

 

I'm guessing that would mean the error must be in application.cfc, but it's
pretty simple and I don't see what might be wrong.  Could the error be
coming from one of the other cfc's even though index is commented out?  Does
Coldfusion attempt to build the map as soon as it see ormenabled = "true"?

 

Here is the error and below that the code for application cfc

 

Thanks,

 

Mark

 

Error casting an object of type java.lang.String cannot be cast to
java.util.Map to an incompatible type. This usually indicates a programming
error in Java, although it could also mean you have tried to use a foreign
object in a different way than it was designed. 



java.lang.String cannot be cast to java.util.Map 

 



 



Resources: 

*   Check the ColdFusion 
documentation to verify that you are using the correct syntax.
*   Search the Knowledge Base 
to find a solution to your problem.



Browser  

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.17)
Gecko/2009122116 Firefox/3.0.17 GTB6 (.NET CLR 3.5.30729)


Remote Address  

127.0.0.1


Referrer  



Date/Time  

14-Jan-10 11:18 AM

 


Stack Trace 


 

java.lang.ClassCastException: java.lang.String cannot be cast to
java.util.Map
   at
coldfusion.orm.hibernate.ConfigurationManager.initConfiguration(Configuratio
nManager.java:63)
   at
coldfusion.orm.hibernate.HibernateProvider.InitializeORMForApplication(Hiber
nateProvider.java:182)
   at
coldfusion.orm.hibernate.HibernateProvider.beforeApplicationStart(HibernateP
rovider.java:85)
   at
coldfusion.filter.ApplicationFilter.fireBeforeAppStartEvent(ApplicationFilte
r.java:475)
   at
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:221)
   at
coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
   at
coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
   at coldfusion.filter.PathFilter.invoke(PathFilter.java:87)
   at
coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
   at
coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
   at
coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74)
   at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistence
Filter.java:28)
   at
coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
   at
coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
   at
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
   at
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
   at
coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
   at coldfusion.CfmServlet.service(CfmServlet.java:200)
   at
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
   at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
   at
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletF
ilter.java:42)
   at
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
   at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
   at jrun.servlet.FilterChain.service(FilterChain.java:101)
   at
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
   at
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
   at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
   at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
   at
jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
   at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:
320)
   at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428
)
   at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:26
6)
   at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

 

 

Application.cfc :

 











 











 




~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/

RE: insert trouble...zero length

2009-06-16 Thread Mark Fuqua MdProfinish

Another quick question...I've noticed elsewhere, that it is common to set a
value to NULL.  Is there a benefit to either of these...

'#transferData. Country #''
',  
 
'#transferData.Country#'NULL,


Thanks,

Mark


-Original Message-
From: Jason Fisher [mailto:ja...@wanax.com] 
Sent: Tuesday, June 16, 2009 2:56 PM
To: cf-talk
Subject: Re: insert trouble...zero length


Actually, empty string simply breaks the Boolean check, it's the primary 
exception.

cfif isBoolean(stringVar) ...

will at least let it through only if it's actually a value that CF can 
apply a true/false test to ...


From: "Peter Boughton" 
Sent: Tuesday, June 16, 2009 2:48 PM
To: "cf-talk" 
Subject: Re: insert trouble...zero length 

Nothing wrong with your mailing list ettiquette - I had to post
manually (hof broke) and just got the subject wrong the first time,
and posted again so it was correctly threaded.

Anyhow, I'd still recommend adding a check against it being missing -
unless you're 300% certain it will always be there.
Slightly confused that it appears to be one of the string fields - an
empty string shouldn't cause an error. :/

-- 
Peter Boughton
//hybridchill.com
//blog.bpsite.net





~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323547
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: insert trouble...zero length

2009-06-16 Thread Mark Fuqua MdProfinish

Thank you Peter, I appreciate what you're saying...it's just that I can look
at the database and see ContactType is present for each record...so while
that, I'm sure, would cause an error, it is not in this case.

Sorry, I only code part time, a couple times each year (trying to go full
time...really amazed...I like coding), so my mailing list etiquette is
pretty rough...I should have responded the first time.  Thanks for the help.


Mark

-Original Message-
From: Peter Boughton [mailto:bought...@gmail.com] 
Sent: Tuesday, June 16, 2009 2:24 PM
To: cf-talk
Subject: Re: insert trouble...zero length


Your problem there is the numeric ContactType field - if it is
missing, you get an empty item between the two commas, which is
invalid SQL syntax.

You can solve it with cfqueryparam by setting the null property based
on whether it contains a numeric value or not:





-- 
Peter Boughton
//hybridchill.com
//blog.bpsite.net



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323544
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: insert trouble...zero length

2009-06-16 Thread Mark Fuqua MdProfinish

Sorry to ask, but does  actually
suffice as a check for length or do I have to add = 0... 

Seems like you're saying I can do the following and it will work:

Values('#myquery.MyFieldName#'"
", REPEAT...)

Thanks,

Mark

-Original Message-
From: Alan Rother [mailto:alan.rot...@gmail.com] 
Sent: Tuesday, June 16, 2009 1:44 PM
To: cf-talk
Subject: Re: insert trouble...zero length


There are several valid ways to handle this.
In your destination table you can define a default value if none is
provided, this of course does require you to do a CFIF around each item in
your insert and you will need to check to see if the value you are about to
insert has a length 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323537
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: insert trouble...zero length

2009-06-16 Thread Mark Fuqua MdProfinish

So I have to put a cfif at each value to check for length greater than zero
and if it is not, set the value to " " for each field...for each iteration?

-Original Message-
From: Rob Parkhill [mailto:robert.parkh...@gmail.com] 
Sent: Tuesday, June 16, 2009 1:42 PM
To: cf-talk
Subject: Re: insert trouble...zero length


You will have to make sure that the table you are inserting into can have a
NULL as a value, or you will need to modify your code to look at each value
and change any NULLs to either a space or a zero depending on the datatype
you are inserting.
HTH

Rob

On Tue, Jun 16, 2009 at 1:33 PM, Mark Fuqua MdProfinish <
m...@mdprofinish.com> wrote:

>
> Having trouble with the following code.having trouble with "zero length"
> values.  The field in the database is empty and when it goes to insert it
> into another table, it chokes.  Is there a way to set a " " value as
> default?  Or do I have to do a cfif on each value?  I'm sure I'm missing
> something simple here.
>
>
>
>
>
> 
>
> SELECT *
>
> FROM plumUser
>
> Where ContactType = 3 and userId = 34
>
> 
>
>
>
>
>
> 
>
> 
>
> INSERT INTO PlumUser(address1,  CellPhone, CellPhoneCarrier,
> CellPhoneEmail,
> City,
>
>  CompanyName, ContactType, Country, DateCreated, Email, Extension, Fax,
> FirstName, HomePhone,
>
>  LastName, OfficePhone, Password, State, Status, SubShortName, UserName,
> ZipCode)
>
>  VALUES( '#transferData.Address1#', '#transferData.CellPhone#',
>
>  '#transferData.CellPhoneCarrier#', '#transferData.CellPhoneEmail#',
> '#transferData.City#',
>
>  '#transferData.CompanyName#',#transferData.ContactType#,
> '#transferData.Country#',
>
>  #CreateODBCDate(transferData.DateCreated)#,  '#transferData.Email#',
> '#transferData.Extension#',
>
>  '#transferData.Fax#',  '#transferData.FirstName#',
> '#transferData.HomePhone#',  '#transferData.LastName#',
>
>  '#transferData.OfficePhone#',  '#transferData.Password#',
> '#transferData.State#',#transferData.Status#,
> '#transferData.SubShortName#',   '#transferData.UserName#',
>
>'#transferData.ZipCode#'  )
>
>  
>
>  
>
>
>
> Thanks,
>
>
>
> Mark
>
>
>
>
>
>
> 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323535
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


insert trouble...zero length

2009-06-16 Thread Mark Fuqua MdProfinish

Having trouble with the following code.having trouble with "zero length"
values.  The field in the database is empty and when it goes to insert it
into another table, it chokes.  Is there a way to set a " " value as
default?  Or do I have to do a cfif on each value?  I'm sure I'm missing
something simple here.

 

 



SELECT *

FROM plumUser

Where ContactType = 3 and userId = 34



 

 





INSERT INTO PlumUser(address1,  CellPhone, CellPhoneCarrier, CellPhoneEmail,
City,

 CompanyName, ContactType, Country, DateCreated, Email, Extension, Fax,
FirstName, HomePhone,

  LastName, OfficePhone, Password, State, Status, SubShortName, UserName,
ZipCode)

  VALUES( '#transferData.Address1#', '#transferData.CellPhone#',  

  '#transferData.CellPhoneCarrier#', '#transferData.CellPhoneEmail#',
'#transferData.City#',  

  '#transferData.CompanyName#',#transferData.ContactType#,
'#transferData.Country#',  

  #CreateODBCDate(transferData.DateCreated)#,  '#transferData.Email#',
'#transferData.Extension#',  

  '#transferData.Fax#',  '#transferData.FirstName#',
'#transferData.HomePhone#',  '#transferData.LastName#',

  '#transferData.OfficePhone#',  '#transferData.Password#',
'#transferData.State#',#transferData.Status#,
'#transferData.SubShortName#',   '#transferData.UserName#',  

'#transferData.ZipCode#'  )

  

  

 

Thanks,

 

Mark

 




~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323531
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4