[ https://issues.apache.org/jira/browse/LABS-456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12755021#action_12755021 ]
Simone Gianni commented on LABS-456: ------------------------------------ A LogicallyNamed interface could be added, beans wanting a logic name should implement it. A default get/setLogicName will be added, and will be included on the database schema with an unique constraint. A default String computeLogicName will be added, calling by default "toUser". computeLogicName will be called only upon persisting the entity, eventually with a JPA listener. The resulting string will be normalized: lowercasing, ignoring any non digit or letter characters and replacing spaces with a "-". If the computed logic name is already present on the table, a random number is added. Database will have a new method to fetch entities based on the logic name. The DatabaseConverter will default to using logic name when LogicallyNamed is present. It will eventually setup proper checks to try interpreting the string first as a primary key, and then as a logical name. > [database] logic names for entities > ----------------------------------- > > Key: LABS-456 > URL: https://issues.apache.org/jira/browse/LABS-456 > Project: Labs > Issue Type: Improvement > Components: Magma > Affects Versions: Current > Reporter: Simone Gianni > Assignee: Simone Gianni > Fix For: Current > > > Currently Magma offers a DatabaseConverter that, given a required class, > parses a primary key passed on the URL and retrieves the entity from the > database. > Having IDs on the URL is not a bad thing itself, but using logic names gives > better search engine optimization. > Moreover, there are a number of situations where hard-fetching an entity from > the Database is needed. For example, in the content fragment, it's possible > to include the list of last X articles froma specific section as a side box. > That method requires a section, which is an entity and must be fetched from > the database. Since this call can be hardwired in the template, a way to > fetch that section without using primary key (id) is needed. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: labs-unsubscr...@labs.apache.org For additional commands, e-mail: labs-h...@labs.apache.org