Search Results

Search found 5 results on 1 pages for 'tuukka mustonen'.

Page 1/1 | 1 

  • How to populate Java (web) application with initial data using Spring/JPA/Hibernate

    - by Tuukka Mustonen
    I want to setup my database with initial data programmatically. I want to populate my database for development runs, not for testing runs (it's easy). The product is built on top of Spring and JPA/Hibernate. Developer checks out the project Developer runs command/script to setup database with initial data Developer starts application (server) and begins developing/testing then: Developer runs command/script to flush the database and set it up with new initial data because database structures or the initial data bundle were changed What I want is to setup my environment by required parts in order to call my DAOs and insert new objects into database. I do not want to create initial data sets in raw SQL, XML, take dumps of database or whatever. I want to programmatically create objects and persist them in database as I would in normal application logic. One way to accomplish this would be to start up my application normally and run a special servlet that does the initialization. But is that really the way to go? I would love to execute the initial data setup as Maven task and I don't know how to do that if I take the servlet approach. There is somewhat similar question. I took a quick glance at the suggested DBUnit and Unitils. But they seem to be heavily focused in setting up testing environments, which is not what I want here. DBUnit does initial data population, but only using xml/csv fixtures, which is not what I'm after here. Then, Maven has SQL plugin, but I don't want to handle raw SQL. Maven also has Hibernate plugin, but it seems to help only in Hibernate configuration and table schema creation (not in populating db with data). How to do this?

    Read the article

  • Passing empty list as parameter to JPA query throws error

    - by Tuukka Mustonen
    If I pass an empty list into a JPA query, I get an error. For example: List<Municipality> municipalities = myDao.findAll(); // returns empty list em.createQuery("SELECT p FROM Profile p JOIN p.municipality m WHERE m IN (:municipalities)") .setParameter("municipalities", municipalities) .getResultList(); Because the list is empty, Hibernate generates this in SQL as "IN ()", which gives me error with Hypersonic database. There is a ticket for this in Hibernate issue tracking but there are not many comments/activity there. I don't know about support in other ORM products or in JPA spec either. I don't like the idea of having to manually check for null objects and empty lists every time. Is there some commonly known approach/extension to this? How do you handle these situations?

    Read the article

  • How to efficiently manage files on a filesystem in Java?

    - by Tuukka Mustonen
    I am creating a few JAX-WS endpoints, for which I want to save the received and sent messages for later inspection. To do this, I am planning to save the messages (XML files) into filesystem, in some sensible hierarchy. There will be hundreds, even thousands of files per day. I also need to store metadata for each file. I am considering to put the metadata (just a couple of fields) into database table, but the XML file content itself into files in a filesystem in order not to bloat the database with content data (that is seldomly read). Is there some simple library that helps me in saving, loading, deleting etc. the files? It's not that tricky to implement it myself, but I wonder if there are existing solutions? Just a simple library that already provides easy access to filesystem (preferrably over different operating systems). Or do I even need that, should I just go with raw/custom Java?

    Read the article

  • Databinding combobox selected item to settings

    - by Tuukka
    I store user specified settings using application settings properties and databinding. It has been working fine, until i want user selected to font for combobox. Databinding between user settings and combobox not working. I want to store font family name. App.XML <Application.Resources> <ResourceDictionary> <properties:Settings x:Key="Settings" /> </ResourceDictionary> </Application.Resources> Window.XML <ComboBox Name="Families" ItemsSource="{x:Static Fonts.SystemFontFamilies}" <!-- This line --> SelectedItem="{Binding Source={StaticResource Settings}, Path=Default.Font, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="57,122,199,118"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}" FontFamily="{Binding}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Settings: font String User Arial

    Read the article

  • Silverlight graphics pixel side position?

    - by Tuukka
    I try to port simple game to silverlight (SameGame). The problem is that my old source code used pixel sizes to allight game marks to board. I draw simple grid using lines and game mark (using rectangle). How i can set rentacle position correctly? Example 20 20 pixels to upper left corner). private void DrawGrid() { LayoutRoot.Children.Clear(); Rectangle r = new Rectangle(); r.Width = 20; r.Height = 20; r.Fill = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0)); r.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0)); r.SetValue(Canvas.LeftProperty, (double)0); r.SetValue(Canvas.TopProperty, (double)0); LayoutRoot.Children.Add(r); Color GridColor = Color.FromArgb(0xFF, 0x00, 0x00, 0x00); for (int y = 0; y < 11; y++) { Line l = new Line(); l.X1 = 0; l.Y1 = 30 * y - 1; l.X2 = 20 * 30; l.Y2 = 30 * y - 1; l.Stroke = new SolidColorBrush(GridColor); l.StrokeThickness = 1; LayoutRoot.Children.Add(l); } for (int x = 0; x < 21; x++) { Line l = new Line(); l.X1 = 30 * x; l.Y1 = 0; l.X2 = 30 * x; l.Y2 = 10 * 30; l.Stroke = new SolidColorBrush(GridColor); l.StrokeThickness = 1; LayoutRoot.Children.Add(l); } }

    Read the article

1