Question Sarvan Ibishov · Jan 29, 2018

<PROPERTY DOES NOT EXIST> *Chapters,Test.Book

Hi. I am newby in Cache. My source code at below. I have problem in Relationship property. Could you please help?

/// Class Test.Book Extends %Persistent{Property Name As %String;Property Author As %String;Property ISBN As %String;Relationship Chapters As Test.Chapter [ Cardinality = children, Inverse = bookid ];}
Class Test.Chapter Extends %Persistent{Property Name As %String;Property Page As %Integer;Relationship bookid As Test.Book [ Cardinality = parent, Inverse = Chapters ];}

then in terminal I am running these commands:

USER>set c1 = ##class(Test.Chapter).%New()
USER>set c1.Name = "Introduction"
USER>set c1.Page = 10
USER>set c2 = ##class(Test.Chapter).%New()
USER>set c2.Name = "Development of DB"
USER>set c2.Page = 13
USER>set b = ##class(Test.Book).%OpenId(1)

USER>do b.Chapters.Insert(c1)

after last command I got "property does not exist". Have you any opinion?

P.S. I compiled source code

Comments

Dmitry Maslennikov · Jan 29, 2018

It would be better if you would show the original error message. Something like this

 ​W b.Chapters1.Insert(c1)
^
<PROPERTY DOES NOT EXIST> *Chapters1,Test.Book

I see only that the problem may happen only if you have not compiled sources. 

0
Sarvan Ibishov  Jan 29, 2018 to Dmitry Maslennikov

I complied sources 5-6 time. Hasn't any reaction. Yes, error looks like this:

USER>do b.Chapters.Insert(c1)
 
DO b.Chapters.Insert(c1)
^
<PROPERTY DOES NOT EXIST> *Chapters,Test.Book

0
Dmitry Maslennikov  Jan 29, 2018 to Sarvan Ibishov

Could you repeat my commands?

USER>do $system.OBJ.Compile("Test.*","cdk-u")

Compilation started on 01/29/2018 08:42:30 with qualifiers 'cdk-u'
Compiling 2 classes, using 2 worker jobs
Compiling class Test.Book
Compiling class Test.Chapter
Compiling table Test.Book
Compiling table Test.Chapter
Compiling routine Test.Book.1
Compiling routine Test.Chapter.1
Compilation finished successfully in 0.691s.

USER>set b = ##class(Test.Book).%New()

USER>w b.Chapters
7@%Library.RelationshipObject

If you got almost the same, your Insert should work

0
Sarvan Ibishov  Jan 29, 2018 to Dmitry Maslennikov

Insert doesn't return any error. Insert worked. Thanks.  So, Problem was with compiling source?

But while run this sql in management portal I couldn't see chapters column.

select * from Test.Book 
0
Dmitry Maslennikov  Jan 29, 2018 to Sarvan Ibishov

Right, the problem was in the compilation. In this case, you can't see this property, but you can have access to book from the chapter. Look at this article in the documentation to get more information about SQL access with relationships

0
Sarvan Ibishov  Jan 29, 2018 to Dmitry Maslennikov

But, I had compiled source from studio :)  Interesting.

Thank you so much.

0
Eduard Lebedyuk · Jan 29, 2018

Consider renaming bookid into Book to have consistent properties names.

0