Hi !
I have a table with many rows, is there any way to find out when a concrete row has been inserted? (I don't have create/update time columns)
Thanks
I am trying to get a JPA implementation of a simple approach to internationalisation. I want to have a table of translated strings that I can reference in multiple fields in multiple tables. So all text occurrences in all tables will be replaced by a reference to the translated strings table. In combination with a language id, this would give a unique row in the translated strings table for that particular field. For example, consider a schema that has entities Course and Module as follows :-
Course
int course_id,
int name,
int description
Module
int module_id,
int name
The course.name, course.description and module.name are all referencing the id field of the translated strings table :-
TranslatedString
int id,
String lang,
String content
That all seems simple enough. I get one table for all strings that could be internationalised and that table is used across all the other tables.
How might I do this in JPA, using eclipselink 2.4?
I've looked at embedded ElementCollection, ala this... JPA 2.0: Mapping a Map - it isn't exactly what i'm after cos it looks like it is relating the translated strings table to the pk of the owning table. This means I can only have one translatable string field per entity (unless I add new join columns into the translatable strings table, which defeats the point, its the opposite of what I am trying to do). I'm also not clear on how this would work across entites, presumably the id of each entity would have to use a database wide sequence to ensure uniqueness of the translatable strings table.
BTW, I tried the example as laid out in that link and it didn't work for me - as soon as the entity had a localizedString map added, persisting it caused the client side to bomb but no obvious error on the server side and nothing persisted in the DB :S
I been around the houses on this about 9 hours so far, I've looked at this Internationalization with Hibernate which appears to be trying to do the same thing as the link above (without the table definitions it hard to see what he achieved). Any help would be gratefully achieved at this point...
Edit 1 - re AMS anwser below, I'm not sure that really addresses the issue. In his example it leaves the storing of the description text to some other process. The idea of this type of approach is that the entity object takes the text and locale and this (somehow!) ends up in the translatable strings table. In the first link I gave, the guy is attempting to do this by using an embedded map, which I feel is the right approach. His way though has two issues - one it doesn't seem to work! and two if it did work, it is storing the FK in the embedded table instead of the other way round (I think, I can't get it to run so I can't see exactly how it persists). I suspect the correct approach ends up with a map reference in place of each text that needs translating (the map being locale-content), but I can't see how to do this in a way that allows for multiple maps in one entity (without having corresponding multiple columns in the translatable strings table)...
Hi, I have a problem with binding in ComboBox. I'd like to bind ComboBox items to ListView columns and as a selected value return value of attached property defined on the selected column.
In example bellow you can see working sample that displays width of selected column. If you try to change SelectedValuePath in ComboBox into (loc:SampleBehavior.SampleValue) you get binding error:
BindingExpression path error: '(u:SearchableListView.SearchMemberPath)' property not found on 'object' ''GridViewColumn'
<Window x:Class="Problem_Sample1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="clr-namespace:Problem_Sample1"
WindowStartupLocation="CenterScreen"
Title="Window1"
Height="300" Width="300">
<DockPanel>
<ComboBox DockPanel.Dock="Top"
x:Name="combobox"
ItemsSource="{Binding Path=View.Columns, ElementName=listview}"
DisplayMemberPath="Header"
SelectedValuePath="Width">
</ComboBox>
<StatusBar DockPanel.Dock="Bottom">
<TextBlock>
<TextBlock Text="Selected column (value): " />
<TextBlock Text="{Binding Path=SelectedValue, ElementName=combobox}" />
</TextBlock>
</StatusBar>
<ListView x:Name="listview">
<ListView.View>
<GridView>
<GridViewColumn Header="Name"
Width="101"
loc:SampleBehavior.SampleValue="201" />
<GridViewColumn Header="Surname"
Width="102"
loc:SampleBehavior.SampleValue="202" />
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</Window>
SampleBehavior.cs
using System.Windows;
using System.Windows.Controls;
namespace Problem_Sample1
{
public static class SampleBehavior
{
public static readonly DependencyProperty SampleValueProperty =
DependencyProperty.RegisterAttached(
"SampleValue",
typeof (int),
typeof (SampleBehavior));
[AttachedPropertyBrowsableForType(typeof(GridViewColumn))]
public static int GetSampleValue(GridViewColumn column)
{
return (int)column.GetValue(SampleValueProperty);
}
[AttachedPropertyBrowsableForType(typeof(GridViewColumn))]
public static void SetSampleValue(GridViewColumn column, int value)
{
column.SetValue(SampleValueProperty, value);
}
}
}
Thanks for any help or suggestion.
In Oracle, a table cluster is a group of tables that share common columns and store related data in the same blocks. When tables are clustered, a single data block can contain rows from multiple tables. For example, a block can store rows from both the employees and departments tables rather than from only a single table:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10713/tablecls.htm#i25478
Can this be done in SQLServer?
Anyone know of a command-line CSV viewer for Linux/OS X? I'm thinking of something like less but that spaces out the columns in a more readable way. (I'd be fine with opening it with OpenOffice Calc or Excel, but that's way too overpowered for just looking at the data like I need to.) Having horizontal and vertical scrolling would be great.
We keep most of our logs in a dedicated database table. We have written custom appenders for log4j and log4net, have a fixed log schema with lots of handy columns, and are quite happy with it.
Is that the "best practice" (for sites smaller in scale than Facebook, where a simple DB table just won't scale)?
Greetings, here is the scenario.
I have and .aspx page with and updatepanel like this
<asp:UpdatePanel id="uPanelMain" runat="server">
<ContentTemplate>
<uc:Calendar id="ucCalendar" runat="server" Visible="true" />
<uc:Scoring id="ucScoring" runat="server" Visible="false" />
</ContentTemplate>
The control ucCalendar is loaded first and it contains a grid like this
<asp:DataGrid CssClass="grid" ID="gridGames" runat="server" AutoGenerateColumns="False" HeaderStyle-CssClass="gridHeader" ItemStyle-CssClass="gridScoringRow"
GridLines="None" ItemStyle-BackColor="#EEEEEE" AlternatingItemStyle-BackColor="#F5F5F5"
OnEditCommand="doScoreGame" OnDeleteCommand="doEditGame" OnCancelCommand="printLineup" OnItemDataBound="gridDataBound">
<Columns>
<asp:TemplateColumn >
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="idGame" Visible="false" />
<asp:BoundColumn DataField="isClose" Visible="false" />
<asp:TemplateColumn HeaderText="Status">
<ItemTemplate>
<asp:Image ID="imgStatus" runat="server" ImageUrl="~/img/icoX.png" alt="icoStatus" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="linkScore" runat="server" CommandName="Edit" Text="Score" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
So when i click the "linkButton", the codebehind of the userControl calls a public method in the .aspx as this:
From the userControl
protected void doScoreGame(object sender, DataGridCommandEventArgs e)
{
((GM)this.Page).showScoring(null, null);
}
From the .aspx page
public void showScoring(object sender, EventArgs e)
{
removeLastLoadedControl();
ucScoring.Visible = true;
}
So, here comes the problem:
There are two postbacks taking place when I change the visible attribute of the ucScoring control.
The first postback is fine, it's handled by the updatePanel.
The second postback is a full postback, and i really don't understand why it is happening.
I'm really lost here, please help!
Thanks
Mat
Any suggestions on the best way to display this table on an Android platform? The formatting is not necessary but I am looking for a flexible way to do this because there are numerous tables with different numbers of rows and columns.
Hi,
I have a project in C# with a Sql-server Database.
In that database I have a table named 'Process' and columns named 'process_name', 'Full_Name' and 'Version' (all of the type:nvarchar(50)).
I want to write a query wich will add the new process, only if it doesn't exist in the table yet.
How can I do that?
Many thanks,
Hi
this is my homework and the question is this:
List the average balance of customers by city and short zip code (the first five digits of thezip code). Only include customers residing in Washington State (‘WA’).
also the Customer table has 5 columns(Name,Family,CustZip,CustCity,CustAVGBal)
I wrote the query like below is this correct?
SELECT CustCity,LEFT(CustZip,5) AS NewCustZip,CustAVGBal
FROM Customer
WHERE CustCity = 'WA'
THANKS!!
I have a DataGridView bound on a generic list, in .NET 3.5.
When this grid is resized, there is a residual traces that is left behind on the background of the grid where there is no items. This only occurs where there is some columns that have the WrapMode attribute set to True. It seems that only the content that is wrapped is not refreshed on the background of the grid.
Anybody have a workaround or a resolution for this problem?
I got table with next columns: Id, Name, Age, Class
I am trying to insert new row in db like this:
INSERT INTO MyTable (Name, Age, Class)
VALUES (@name, @age, @class)
And get an exeption:
"Index or primary key cannot contain a Null value."
The question is how to add a new row without knowing next primary Id, or maybe there is a way to get this Id from the table with the help of another query ?
When we command "net use" on command prompt, the result has four columns.
Status Local Remote Network
OK Z: \\10.x.x.x\Public Microsoft Windows Network
X: \\10.y.y.y\Public My Network Redirector
The Microsoft Windows Network(SMB)'s Status has OK value, but we don't. It's just empty.
We implemented NPEnumResource function in our Network Provider dll.
But I don't know how can I set the value(OK).
How can I do that?
Thanks
How to store java.util.Calendar field into one column with Datanucleus JDO. By default it is stored into two columns (millisecs, Timezone) with following JDO metadata.
field name="startDate" serialized="true" embedded="true"
persistence-modifier="persistent"
What need to be changed in metadata to store it into single column (Timestamp)?
Is it posible query (JDOQL) on calendar field when it is in two clumn?
I'm building a windows mobile app. And using SqlCe.
I'm looking for a good sql query builder. So instead of writing "SELECT COLUMNS FROM TABLE WHERE etc...
Is there a good free library that can build this sort of query?
Consider a grocery store scenario (I'm making this up) where you have FACT records that represent a sale transaction, where the columns of the Fact table include
SaleItemFact Table
------------------
CustomerID
ProductID
Price
DistributorID
DateOfSale
Etc
Etc
Etc
Even if there are duplicates in the table when you consider ALL the keys, I would contend that a surrogate running numeric key (i.e. identity column) should be made up, e.g., TransactionNumber of type Integer.
I can see someone arguing that a Fact table might not have a unique key (though I'd invent one and waste the 4 bytes, but how about a dimension table?
Given a JTable where one of the columns contains a number, how do I display this number as a currency? I.e. 5 should display as $5.00 etc.
Can this be done directly on the JTable after it has been populated with data, or do I have to do this earlier? Thanks.
using Nhibernate;
I'm trying to insert several values a on table which has an unique index on some columns.
I'd like to know if a particular insert raises an exception for having violated the unique constraint.
So, which particular exception type should i catch? I only want to catch this particular one and let all others go up.
Thanks a lot!
Which is the most effective way to sum data in the DataTable by a given criteria?
I have the following table:
KEY_1
KEY_2,
VALUE_1,
VALUE_2
Input:
01101, P, 2, 3
01101, F, 1, 1
01101, P, 4, 4
10102, F, 5, 7
Desired output (new DataTable):
01101, P, 6, 7
01101, F, 1, 1
01101, SUM, 7, 8
10102, F, 5, 7
10102, SUM, 5, 7
I need efficient algorithm, because I have 10k rows and 18 columns in a DataTable.
Thank you.
How would I do to check if a email actially exists?
Cant understand how sites do to send mails with a unique link that the users clicks to validate that he is the owner of email =/
Make a 2 new columns called activationkey and activated and store some random string, send an email with the activationkey, and update the users activated =1 that match that activation link
register.php?a=activate&key=9cdfb439c7876e703e307864c9167a15
Any better ideas?
I was wondering if there is a nice IF NOT EXISTS for checking columns and indexes in SQLite, or do I need to bring back the entire database schema and validate against that?
the code I wrote only tells me how many students have the same age. I want their names too...
SELECT YEAR(CURRENT DATE-DATEOFBIRTH) AS AGE, COUNT(*) AS HOWMANY
FROM STUDENTS
GROUP BY YEAR(CURRENT DATE-DATEOFBIRTH);
this returns something like this:
AGE HOWMANY
--- -------
21 3
30 5
Thank you.
TABLE STUDENTS COLUMNS:
StudentID (primary key), Name(varchar), Firstname(varchar), Dateofbirth(varchar)
I was thinking of maybe using the code above and somewhere add the function concat that will put the stundents' names on the same row as in
There are four regions with more than one million records total. Should I create a table with a region column or a table for each region and combine them to get the top ranks?
If I combine all four regions, none of my columns will be unique so I will need to also add an id column for my primary key. Otherwise, name, accountId & characterId would be candidate keys or should I just add an id column anyways.
Table:
----------------------------------------------------------------
| name | accountId | iconId | level | characterId | updateDate |
----------------------------------------------------------------