Subsonic Three (3) CreatedBy fields not updating - subsonic

Using Subsonic 3 I have the fields:
o CreatedOn (datetime)
o CreatedBy (nvarchar(50))
o ModifiedOn (datetime)
o ModifiedBy (nvarchar(50))
When I add data to my table it is not adding data to these columns. Am I missing something?

These fields aren't automatically populated in version 3 like they were in version 2, unless you are using the ActiveRecord templates. You could modify the templates pretty simply to add the functionality yourself.

Related

JOOQ join two tables with same column names

I'm using running following JOOQ query:
dsl.select().from(table).join(joinTable).on(joinCondition).where(condition).fetchInto(entityClass);
Both table and joinTable have id as primary key name, but resulting fetch into entity class contains id of joinTable, and rest of columns of table. If I reorder tables, result is similar, I have ID from table and rest of columns from joinTable.
Metamodel is generated using jooq-codegen-maven plugin.
Interesting, I found out that using:
dsl.select(table.fields())...
solves problem. I would expect that this behavior is by default, but it is not.

how to add a multi column unique index in Jhipster?

the entity generator does not seem to support composite unique keys, is the suggested way to get around this just to create 1 unique field with the concatenated values maybe ? e.g.
pkCol uniqueMultiCol unique_field1| unique_field2| unique_field3
1 a_b_c a b c
or maybe add a liquibase migration to add the unique multi column index?

Frozen keyword in cassandra

No matter if i use or do not use frozen keyword with UDT, it is updating records.
I have table user:
CREATE TABLE demokeyspace.user (
userid text PRIMARY KEY,
address1 frozen<address>,
password text,
uname text
)
and address type:
CREATE TYPE demokeyspace.address (
street text,
city text,
zip_code int
);
It is updating street:'updated street' and city and zip_code to null
As per Cassandra, it does not allow update of UDT values if it is declared as FROZEN.
can somebody help me on this ?
If you use not-frozen UDT, and want to update one field, then you can use following (see docs):
update user set address1.street='updated street' where userid='2';
In your case, you're updating the full address1 field with UDT that has only one value inside...
In case if you're using frozen UDT, you must to specify all values during update, something like you're doing right now, but providing all values.
Use of frozen values is encouraged if you're always updating the full record, but if you'll need to update parts of the record, you shouldn't use it.

Cassandra how can I simulate a join statement

I am new to cassandra and am coming from Postgres. I was wondering if there is a way that I can get data from 2 different tables or column family and then return the results. I have this query
select p.fullname,p.picture s.post, s.id, s.comments, s.state, s.city FROM profiles as p INNER JOIN Chats as s ON(p.id==s.profile_id) WHERE s.latitudes>=28 AND 29>= s.latitudes AND s.longitudes
">=-21 AND -23>= s.longitudes
The query has 2 tables: Profiles and Chat and they both share a common field Chats.id==Proifles.profile_id it boils down to this basically return all rows where Chat ID is equal to Profiles id. I would like to keep it that way because now updating profiles are simple and would only need to update 1 row per profile update instead of de-normalizing everything and updating thousands of records. Any help or suggestions would be great
You have to design tables in way you won't need joins. Best practice is if your table matches exactly the use case it is used for.
Cassadra has a feature called shared static columns; this allows you to bind values with partition part of primary key. Thus, you can create "joined" version of table without duplicates.
CREATE TABLE t (
p_id uuid,
p_fullname text STATIC,
p_picture text STATIC,
s_id uuid,
s_post text,
s_comments text,
s_state text,
s_city text,
PRIMARY KEY (p_id, s_id)
);

Simple way to use Foreign Key values for sorting?

Disclaimer: I jumped to C# 2008 recently and SubSonic 3 (3.0.0.4) at the same time. I haven't used Linq for much of anything in the past.
Is there an easy way to use the foreign key display value for sorting, rather than the FK Id (which is numeric)?
I've added a new Find method in my ActiveRecord.tt to help with sorting based on a string field name but after doing some testing I realized that even though its working as it should be, I am not handling foreign key fields at all (they are just sorting by their value).
Even if I need to change how I am accessing the data it is early enough in the project to do that. Just looking for suggestions.
LINQ is your friend in this situation, you just need to join your two objects and then sort by the property from your foreign object:
var primaryObjectsSorted =
from primaryObjects in PrimaryObject.All()
join foreignObjects in ForeignObject.All()
on primaryObjects.ForeignId equals foreignObjects.Id
orderby foreignObjects.PropertyYouWantToSortOn
select primaryObjects;
So you have table A which has id of table B as a foreign key and you want to sort table A by the DisplayName column of table B rather than the id of table B?
The only way to achive this is by a join.
SELECT tableA.* FROM tableA INNLER JOIN tableB ORDER BY tableB.DisplayName
In SubSonic2 you can do that, and still be able to update your records if you use the DB.Select(...).ExecuteCollection() method.
I think this should be possible with subsonic3, too.
Howevery, if you don't use the foreign key and the display name is unique, you should just use this value as your foreign key.

Resources