Benefits of ColdFusion ORM in Blog
posting and saving IP Addresses through HQL, SQL Database functions and
Queries.
Ever
since reading about High quality Performance MySQL, some years ago IP addresses
were stored in the database as integers. Generally people use VarChar (15)
columns to store IP addresses. Actually, an IP address is an unsigned 32-bit
integer and not a string at all. The dotted-quad notation is just a simple way
of writing it out so that humans can read and understand it more easily. You
should be able to store IP addresses as unsigned integers always. MySQL
provides some special functions such as INET_ATON() and INET_NTOA() to convert
between the two representations. Although HQL supports various SQL functions,
but it doesn't include vendor-specific ones such as INET_ATON () and INET NTOA ().
Effective in relation between
Blog entry and Blog Comment
Of
course I could have added simple SQL queries to store the IP data separately
each time an entity was saved, but this seems like unnecessary extra work. I
found some another option to create a "pre-processing" function for conversion
of IP string to an integer before saving but it was not worthwhile. Let’s consider
the relationship between BlogEntry and BlogComment. If you will recall, it is a
bidirectional relationship, where a Blog Entry contains many Blog Comments, and
a Blog Comment contains one Blog Entry.
Technical Expertise and
Initialization of ColdFusion ORM
You
have to first setup your normal ORM settings such as ColdFusion ORM enabled,
and the data source connection and design. In the ColdFusion ORM
settings you have to work with various event handling and event handler. Event
handling is false by default and therefore it will not broadcast these events
that you want to listen to. Also the database creates setting must be set to
update unless you already have these fields added to your table.
By object types for an Efficient
Layout
The
best practice is to use packaging by functionality in all possible ways. This
develops better packaging layouts and maintainability. Below is an example from
an application's model or layer folder:
Model + remote-api + security + products +
util + users + conversions
Class/ Interface
/ Component/ names should be nouns, as they represent some things or objects.
They should be written in camel case such as the first letter capitalized for
each word. You need to use whole words and avoid abbreviations and acronyms if
possible. Interfaces should begin with the letter I. Base or abstract classes
should be denoted in the proper name as well as either Base Class or Abstract Class.
For Examples: URL Converter, RSS Reader, iSearch Engine, Base Entity, and Abstract
Logger, etc
When it needs to deal with inheritance-based
objects, there are 3 methods available, but to me, only 2 of them seem
relevant; these are the 2 methods in which the sub-classes are being stored in
their own tables. Among these 2 methods of persistence, the only difference is
that someone uses a discriminator or differentiator in the base table and one
does not use. ColdFusion ORM 9
Inheritance function for UML Diagram is also useful. We can have many projects
such as Game rental, DVD rental domain based projects. In these projects, each
of the sub-classes contains a foreign key reference to the primary key of the
Rental record as well as its own, specialized information. By keeping this
design in mind, let's have a look at our ColdFusion components.
No comments:
Post a Comment