Kristofer Hindersson

+ Follow
since Jan 19, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kristofer Hindersson

I never use reverse engineering tools as the resulting diagrams tend to look sloppy. I prefere to go the extra mile and use a regular graphics editor (like Inkscape) and create a template with a symbol library by hand. That way I can make my diagrams look the way I intended.
After three days of trying to get jdbcrealm working on Glassfish I give up. I've checked out every tutorial I can find and I've followed the prescribed steps in the Glassfish admin console help section and absolutely nothing happens when I attempt to access secured pages (i.e. no authorization takes place). I've set the monitoring to HIGH for security and the only messages I get is that of the successfull creation of the jdbcrealm. I get no error messages whatsoever. Most frustrating experience to date. -.-'
8 years ago
Apparently it's even worse than I thought and you are forced to use natural keys...
Thank you for your reply but I'm afraid you may have misunderstood my question: I was wondering whether it would be possible to create my own authetication control by utilizing the fact that pages placed inside the WEB-INF folder are not accesible directly through a web browser. My idea was that I could somehow give access to these restricted pages programmatically via a method in a managedbean(?) if a user checked out against the corresponding users-table in the database. My reason for wanting to do this is that I find the whole concept of setting up a jdbcrealm unintuitive and I don't like the constraints it places on my table design. Also I dislike having to mess around with xml-files.
8 years ago

I'm trying to setup a jdbcrealm in Glassfish with MySQL and I can't find any complete examples on how to do this. All the examples I've seen so far just assumes that you're going to insert the appropriate values directly into the tables, but what about the corresponding JPA entities and the mappings between them? If I have the following tables (following the jdbcrealm standard):


Won't this result in two entities with a unidirectional @ManyToOne-mapping going from Group to User and wouldn't that be considered to be a "faulty" mapping? The rigidity of the requirements on the table setup when using jdbcrealm with Glassfish appears akward and unintuitive to me.

As a part of a assignment we're supposed to implement a user login to restricted pages. Now I know that you're supposed to use j_security_check or configure security realms on your application server for this kind of problem but I was wondering whether it would pe possible to put the restricted xhtml-pages inside the WEB-INF folder and give access to these programatically via the application's own classes (controllers or managed beans), i.e. would it be possible to do something like this:

With a setup like this:

...Or will something like this not work at all?

I would appreciate any suggestions on better ways (maybe you can do this kind of thing directly inside a JSF 2 tag?) of solving this that doesn't involve hacking xml-files or setting up security realms and stuff like that.

8 years ago
Myself and a fellow student have been discussing whether or not we should separate the GUI (Swing) from the client logic (TCP socket) in our program altogether. She's the die-hard proponent for separate classes for everything among us two, and in general I agree with her ideas that one should always try to separate the GUI from the logic but I also think theres a point of diminishing returns beyond which it causes more trouble than it's worth to try to force a separation. What are your thoughts on this and how do you usually go about designing your client class?

Our approach atm. is pretty straightforward. If we want to send something to the server we simply enter it into a JTextField, press a send-button and the SendButtonListener writes the content to the server using PrintWriter like this:

Is there a better (more OO-friendly) way of doing this kind of thing? Because I can't imagine how that would be done without the code becoming more confusing to read.

(P.S. I know I haven't given much information of the actual application to go on, but I was hoping to make this more of a general question about how far you should take the idea of separating the gui from the logic.)

Thanks for the replies. I got it working by rebuilding the whole project (Spring MVC). I have no idea what I did differently but now I have another problem:

I have the following classes:

Here's my Criteria method in my ServiceImpl:

pretty straighforward was my thought, but this Criteria causes the following exception:

Cameron Wallace McKenzie wrote:No, it looks like you're doing it correctly.

Why not try a query like the following, without the Example. The following should just return all the data from the database. See if you can do a criteria query without the Example first. Then, when that works, let's move onto seeing if the Example class is the problem.

Whadya think?

Well if I use FetchMode START or ANYWHERE, or if I use the default (EXACT) and sets more than one attribute in the Person-instance, qbe will work. But if I only set the firstname-attribute before creating the example, the Criteria won't return any result. I wonder if this has anything to do with that I have more than one 'Paul' present in the database?
Hi, I have a class Person with these attributes: firstname:String, lastname:String and birthday:Date.

I'm trying to use the Hibernate Criteria API by creating a new Person and setting some of the attributes with values that I want to query the database against.

Person person = new Person();

I then create a new Example thus:

Example example = Example.create(person);

...after which I create the Criteria:


The problem is that this doesn't return any result (empty list) even though I know for certain that there is row where the firstname-column contains 'Paul'. What am I doing wrong here? Have I completely misunderstood the usage of Example together with Criteria?
Hi, I'm having difficulties understanding how to persist a bean/pojo/class with a collection holding another pojo. How should I go about solving the following example:

I have these two entities:

and I've created a database with these tables:

Now let's say that I already have an author with a populated bibliography and I want to persist this to the database.

What I already tried was using hibernates merge by calling this method:

Like this

Unfortunately this doesn't seem to work as the foreign key author_id in books is never set (NULL).

What should I be doing different?
I'm trying to create and populate a simple database to test queries against and I'm using inheritance. Should I use VARCHAR for DTYPE or is it something else?

thanks in advance!

Hi, thanks for another quick reply. The scenario I've depicted is one I made up to illustrate the hypothetical situation of a non-linear inheritance. I used your example from Hibernate made easy as a base. The problem is that the book only deals with the linear case of inheritance (Ancestor <- Parent <- Child). Let's say that I have a Person-class which holds attributes like firstname and lastname and then want to create the two classes Administrator (with a password attribute) and User, both of which extends Person. I don't want the administrators password to be stored in the same table as that of the user and I don't want use separate tables for Person, Adminstrator and User etc. Would hibernate support using the single table strategy, only separately for Person<-Administrator and Person<-User? I hope I'm not confusing the issue..

Regarding the DTYPEs I just put them there thinking it would be how it would work out (it's probably wrong though?)

Hi, is this possible (using hibernate or-mapping):

...and how would I go about it?

/Regards Kris
Hi again

I'm mucking about with inheritance now and I was wondering about how to use the @Table annotation in this case.

What if I have Ancestor, Parent and Child and I want to use the single table strategy to map inheritance among these classes. Now what if I wanted the single table thus created to be called "family", how would I go about it? Is it enough to to put @Table(name="family") in the Ancestor-class?

Or must I have @Table(name="family") in every class?