gorm

How to encrypt/decrypt columns in a Grails domain class?

陌路散爱 提交于 2019-12-04 14:29:45
As i want to introduce some data security i was wondering if it is possible to encrypt/decrypt specific columns in a Grails domain class and if so what the easiest way is to achieve such a thing? Let say i have a User class and want to encrypt ssn number or bankaccount number so these are not stored as plain text in the DB.. what would be the best approach? I created the jasypt encryption plugin for doing exactly this. Docs are on the linked bitbucket wiki and there's also slides from a presentation that I've given on it's use. It makes it easy to just annotate your domain classes to do field

Grails: No signature of method findAll() is applicable for argument types: String, ArrayList

喜你入骨 提交于 2019-12-04 14:18:31
问题 I'm new to grails and receive the following error: No signature of method: Something.findAll() is applicable for argument types: (java.lang.String, java.util.ArrayList) values: [from Something AS s WHERE s.some_number LIKE ?, [%asdf%]]" The error occurs when I run test-app . It occurs in the following place: SomethingVO[] findBySomeNumber(String searchString) { searchString = "%"+searchString+"%" return Something.findAll("from Something AS s WHERE s.some_number LIKE ?",[searchString]).collect

How to set uniqueness at DB level for a one-to-many association?

不想你离开。 提交于 2019-12-04 13:52:08
问题 My problem is simple but I could not find any GORM syntax for this. Consider the following class: class Article { String text static hasMany = [tags: String] static constraints= { tags(unique: true) //NOT WORKING } } I want to have one unique tag name per article defined in my constraints but I cannot make it with the above syntax. Clearly I need in DB schema something like: create table article_tags (article_id bigint, tags_string varchar(255), unique (article_id , tags_string)) How can I do

How to override the DomainClass.list() in GORM (Grails)

☆樱花仙子☆ 提交于 2019-12-04 12:45:12
People, I'm facing a problem with grails GORM , my Application is totally dependent of the DomainClass.list() method, it is in all of my create/edit GSPs, but now I need a particular behavior for listing objects. Being more specific I need to filter these lists (All of them) by one attribute. The problem is I'm hoping not to change all the appearances of these methods calling, so is there a way to customize the behavior of the default list() method ? I need it to function just the way it does, but adding an ending filter. Maybe you can use hibernate filter plugin (see here ). This will allow

Grails: One Database and more than one application

风格不统一 提交于 2019-12-04 12:41:12
I am having Grails GORM based application.One web service and one website both are running on different port and sharing common database and tables. What i have done is created domain class for both application which are having same fields and domain class name.For example Registration table having userName and password fields.One can register through web service and also from website. My current applications is working fine...but is it a feasible solution..? Thanks, Viral You could run into race/locking conditions but I've seen this done on many occasions. My only suggestion is that you not

how to get distinct results using Projections and Criteria

徘徊边缘 提交于 2019-12-04 11:44:06
问题 I am trying to load distinct Parents using Criteria in Grails. The query is as following Query: def criteria = Parent.createCriteria(); results = criteria.list(max:params.max, offset:params.offset){ projections{ groupProperty('id') } children{ books{ like('title',"%book") } } order("id","asc") } Domain Classes class Parent { String name static hasMany = [children:Child] static constraints = { } } class Child { String name Parent parent static belongsTo = [parent:Parent] static hasMany =

Overriding event closure on Grails GORM domain class for unit testing

断了今生、忘了曾经 提交于 2019-12-04 09:54:24
I'm working on a fresh Grails project and recently noticed the default convention in the Spring Security Core generated User class now auto-encodes the password via a beforeInsert/Update event. That's a nice, clean, DRY way of doing the encode, and also makes it impossible to forget to do so. However, now when trying to write up some unit tests which make use of said User class, I find I either have to mock out the springSecurityService (due to the encode), or more preferably (and cleanly), I'd just override the beforeInsert/Update closure with one that does nothing. Typically in Groovy one

GORM default Date format when sending date to Grails

天涯浪子 提交于 2019-12-04 09:23:02
I am sending a JSON PUT request to Grails. In the JSON object, I have a date string. I have searched and experimented, but I cannot determine the default date string format that GORM wants to parse the date string. In all my attempts I get the following error: java.lang.IllegalArgumentException: Could not parse date: Unparseable date I just want to know the default format GORM expects and I will happily format the date string in that format before sending it to the server. dmahapatro I suppose you face this issue during data binding. Reason: Default date format for binding is yyyy-MM-dd HH:mm

Grails 2.4.2 - Dynamically referencing default datasource

余生颓废 提交于 2019-12-04 09:21:37
This question has been partly answered here but there is still an issue with referencing the default datasource dynamically. I'm working on an internal application that allows developers to modify configuration settings for one of our multi-tenant applications and push those settings from dev to testing, staging and production. Each one of these will have their own datasource, and the Grails app will be installed on each developer's computer. The local datasource will be the default one, and then dataSource_testing, dataSource_staging and so on will reference the appropriate environments. I

Why is GORM not saving my object?

拈花ヽ惹草 提交于 2019-12-04 09:17:32
问题 If I execute this code in the Grails console: def p = new Post(title: "T"); p.save(flush: true); // or p.save(); Post.count(); GORM is not throwing any exceptions, but the data is not saved in my DB. What am I doing wrong? 回答1: It's likely you have a constraint violation. Add failOnError: true to your save method parameters. Then you'll get an exception when your save fails. (Alternatively you can check the return value from save, and if it's false print out p.errors.allErrors() .) Validation